The topic has been discussed many times by many people (see the references below). This post just documents what I did to use a Company Certifying Authority to configure SSL for Tomcat.
1. create a keystore file
c:\jdk1.6.0_21\bin\keytool -genkey -alias myalias -keystore mykeystore \
-genkeypair -keyalg RSA -keysize 2048
Enter keystore password:
Re-enter new password:
What is your first and last name?
[myhostname.mycompanyname.com]: myhostname.mycompanyname.com
What is the name of your organizational unit?
[Unknown]: ITS
What is the name of your organization?
[ITS]: MyComp Software, Inc
What is the name of your City or Locality?
[My City]: My City
What is the name of your State or Province?
[MyState]: MyState
What is the two-letter country code for this unit?
[US]: US
Is CN=myhostname.mycompanyname.com, OU=ITS, O="MyComp Software, Inc", \
L=My City, ST=MyState, C=US correct?
[no]: yes
Enter key password for <myalias>
(RETURN if same as keystore password):
The first and last name will be used to identify the server that would use the certificate. It has to be the server name you want users to identify the server.
The alias (myalias in the sample) can be anything that identifies the certificate. Just needs to make sure the later reference is consistent.
The result of above command will be a keystore file.
2. Generate a Certificate Signing Request (CSR) for the keystore created from last step
c:\jdk1.6.0_21\bin\keytool -certreq -alias myalias -keystore mykeystore \
-keyalg RSA -file mycertreq.csr
Enter keystore password:
Please note the usage of myalias, keystorename, and mycertreq.csr. The first two have to be the same from step 1. The latter can be named as you want.
The result of this step is the CSR file, mycertreq.csr.
3. verify the certificate request from VeriSign website:
Just copy and paste the file myertreq.csr into the enrollment form shown by CSR validator from Verisign (open the file in a text editor that does not add extra characters). The verification would check several parameters defined in CSR file. If everything is checked OK, then we can move to the next step.
Actually, the above three steps were documented in Certificate Signing Request (CSR) Generation Instructions- Tomcat.
4. Send the CSR file to the company Certifying Authority(CA) specialist and get it signed
The CA specialist would return two file, one is the company CA certificate file. Another is the signed certificate file for my CSR file created in last step.
Different companies may use different procedures for this. That’s what I have gone through.
5. Import the certificates
Now that you have your certificate you can import it into you local keystore.
Actually, there are several smaller steps involved:
a- Make a copy of the keystore file you created in step 1:
This is only for a backup. As you read further, the original keystore file will be changed when importing certificates to it. It’s better to make a copy in case you want to start all over again.
b-Import a Chain Certificate or Root Certificate into keystore:
Remember the two files I got from company CA, one is the company CA certificate file, say CompanyCA.crt.txt. First, we have to import it into the local keystore. Please note the alias used here is root.
c:\jdk1.6.0_21\bin\keytool -import -alias root -keystore mykeystore -trustcacerts -file CompanyCA.crt.txt
Enter keystore password:
Owner: CN=MyComp Certifying Authority, O=MyComp Software, L=My City, ST=MyState, C=US
Issuer: CN=MyComp Certifying Authority, O=MyComp Software, L=My City, ST=MyState, C=US
Serial number: 0
Valid from: Tue Dec 14 09:48:58 CST 2004 until: Tue Dec 31 09:48:58 CST 2024
Certificate fingerprints:
MD5: D7:1B:39:8A:1A:C9:40:89:1D:20:2E:CA:DE:EF:5A:C9
SHA1: 48:48:98:9A:42:5A:52:44:EC:C4:FB:2E:4B:11:4A:32:60:49:41:4B
Signature algorithm name: MD5withRSA
Version: 3
Extensions:
#1: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: EB 74 BE 70 76 47 4A A0 D0 D8 9D 5F 68 EB E0 F3 .t.pvGJ...._h...
0010: 1E 36 AA A4 .6..
]
]
#2: ObjectId: 2.5.29.19 Criticality=false
BasicConstraints:[
CA:true
PathLen:2147483647
]
#3: ObjectId: 2.5.29.35 Criticality=false
AuthorityKeyIdentifier [
KeyIdentifier [
0000: EB 74 BE 70 76 47 4A A0 D0 D8 9D 5F 68 EB E0 F3 .t.pvGJ...._h...
0010: 1E 36 AA A4 .6..
]
[CN=MyComp Certifying Authority, O=MyComp Software, L=My City, ST=MyState, C=US]
SerialNumber: [ 00]
]
Trust this certificate? [no]: yes
Certificate was added to keystore
c- Then we need importing the signed Certificate, myserver.crt.txt.
c:\jdk1.6.0_21\bin\keytool -import -alias myalias -keystore mykeystore -trustcacerts -file myserver.crt.txt
Enter keystore password:
Certificate reply was installed in keystore
Please note the usage of myalias, and mykeystore. Both are consistent from all previous steps.
d- You may want to check what inside the keystore is saved right now to get an idea about the results of importing certificates.
c:\jdk1.6.0_21\bin\keytool -list -keystore mykeystore
Enter keystore password:
Keystore type: JKS
Keystore provider: SUN
Your keystore contains 2 entries
root, Nov 10, 2010, trustedCertEntry,
Certificate fingerprint (MD5): D7:1B:39:8A:1A:C9:40:89:1D:20:2E:CA:DE:EF:5A:C9
myalias, Nov 10, 2010, PrivateKeyEntry,
Certificate fingerprint (MD5): A8:C5:37:7B:78:2D:A9:95:1E:62:8E:1B:9E:82:CE:17
6. Edit the Tomcat Configuration File
This is the last step for the configuration. SSL Configuration How to has detailed explanation and steps to do that. Here is my configuration for Tomcat 6.x.
<-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 -->
<Connector protocol="org.apache.coyote.http11.Http11Protocol"
port="8443" maxThreads="200"
scheme="https" secure="true" SSLEnabled="true"
keystoreFile="${user.home}/mykeystore" keystorePass="changeit"
clientAuth="false" sslProtocol="TLS"/>
Please note the location of mykeystore and the usage of keystore password.
Then you can start Tomcat to get HTTPS supported from Tomcat for your web applications.
Reference:
Certificate Signing Request (CSR) Generation Instructions- Tomcat
SSL Checker
Apache 2 with SSL/TLS: Step-by-Step
A Simple Step-By-Step Guide To Apache Tomcat SSL Configuration
Set up secure web service with Tomcat and Apache