Monday, April 6, 2015

Https - Configure SSL/HTTPS support on Apache Tomcat 7

■ Configure SSL/HTTPS support on Tomcat 7
 -(sample-test.sample.local -> sample)
 -(JKS -> Java KeyStore)
$ /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/bin/keytool -genkey -alias sample -keyalg RSA -keystore /Users/kim_joon/tomcat/conf/sample.jks
Enter keystore password:   # -> sample
Re-enter new password: # -> sample
What is your first and last name?
  [Unknown]:  Joon Kim
What is the name of your organizational unit?
  [Unknown]:  sample
What is the name of your organization?
  [Unknown]:  sample
What is the name of your City or Locality?
  [Unknown]:  tokyo
What is the name of your State or Province?
  [Unknown]:  shibuya
What is the two-letter country code for this unit?
  [Unknown]:  jp
Is CN=Joon Kim, OU=sample, O=sample, L=tokyo, ST=shibuya, C=jp correct?
  [no]:  yes

Enter key password for <sample>
(RETURN if same as keystore password):                                                    # -> testtest
Re-enter new password:        # -> testtest


■ For confirming a JKS file
$ /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/bin/keytool -list -keystore /Users/kim_joon/tomcat/conf/sample.jks
Enter keystore password:     # -> sample

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

cyberagent, Apr 6, 2015, PrivateKeyEntry,
Certificate fingerprint (SHA1): 9F:36:89:8E:B5:06:86:20:B3:47:BF:E4:94:87:0F:C0:FF:87:A9:C4

■ Configure the server.xml in Tomcat7.
 @Before
    <!-- $TOMCAT_HOME/conf/server.xml -->
    <!--
    <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
               maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->
 @After
    <!-- $TOMCAT_HOME/conf/server.xml -->
    <Connector port="8443" protocol="HTTP/1.1"
               maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS"
               keystoreFile="conf/sample.jks"
               keystoreType="JKS"
               keystorePass="sample"            
               keyPass="sample"/>

No comments:

Post a Comment