HTTPS Tomcat Configuration
Accepted format for keystore
- JKS
- PKCS11
- PKCS12 (an internet standard, can be manipulated thru openssl)
JKS
Import root certificate (certificate of the CA where your certificate is signed)
1234keytool -import -trustcacerts \-alias root \-file RootCertFileName.crt \-keystore keystore(
Or MAYBE copy the keystore from jre as the basecp $JAVA_HOME/lib/security/cacerts keystore
orcp /etc/ssl/certs/java/cacerts keystore
)Import the certificate signed by a CA
1234keytool -import \-alias tomcat \-keystore keystore \-file <your_certificate_filename>
PKCS12
Prepare the certificate keystore
Importing an existing certificate into a PKCS12 keystore
JSSE
JSSE implementation is provided as part of the Java runtime.
APR (recommended)
APR (native) implementation uses the OpenSSL engine by default, more faster than JSSE approach.
web.xml
If you want to ensure resources in your application is only be accessable thur https, you can configure the web.xml in your application:
APR Installation
Compile APR
wget http://apache.fayea.com/apr/apr-1.5.2.tar.gz wget http://apache.fayea.com/apr/apr-iconv-1.2.1.tar.gz wget http://apache.fayea.com/apr/apr-util-1.5.4.tar.gz tar -xvf apr-1.5.2.tar.gz tar -xvf apr-iconv-1.2.1.tar.gz tar -xvf apr-util-1.5.4.tar.gz ( cd apr-1.5.2 ./configure --prefix=/usr/local/apr make sudo make install ) ( cd apr-iconv-1.2.1 ./configure --prefix=/usr/local/apr-iconv --with-apr=/usr/local/apr make sudo make install ) ( cd apr-util-1.5.4 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr --with-apr-iconv=/usr/local/apr-iconv/ bin/apriconv make sudo make install ) ( cd $CATALINA_HOME/bin/ tar -xvf tomcat-native.tar.gz cd tomcat-native-*-src/native ./configure --with-apr=/usr/local/apr --with-java-home=`echo $JAVA_HOME` make sudo make install )
Configure Tomcat to Use APR
vim $CATALINA_HOME/bin/catalina.sh, add the following to the beginning of the content: