Tomcat安装CA证书(详细过程篇)
1.创建一个本地证书:
C:\j2sdk1.4.2_05\bin>;keytool -genkey -alias tomcat -keyalg RSA -keystore keystore
输入keystore密码: 12345678
您的名字与姓氏是什么?
[Unknown]: www.test.com
您的组织单位名称是什么?
[Unknown]: system
您的组织名称是什么?
[Unknown]: test
您所在的城市或区域名称是什么?
[Unknown]: beijing
您所在的州或省份名称是什么?
[Unknown]: beijing
该单位的两字母国家代码是什么
[Unknown]: cn
CN=liujx, OU=system, O=test, L=beijing, ST=beijing, C=cn 正确吗?
[否]: y
输入<tomcat>;的主密码
(如果和 keystore 密码相同,按回车):
查看证书
C:\j2sdk1.4.2_05\bin>;keytool -list -keystore keystore
输入keystore密码: 12345678
Keystore 类型: jks
Keystore 提供者: SUN
您的 keystore 包含 1 输入
tomcat, 2004-11-26, keyEntry,
认证指纹 (MD5): B8:44:A1:A2:C7:9A:09:EE:A0:CF:5B:AA:DC:F7:0F:80
2.然后创建CSR:
C:\j2sdk1.4.2_05\bin>;keytool -certreq -keyalg RSA -alias tomcat -file certreq.csr -keystore keystore
输入keystore密码: 12345678
现在,你有了一个叫certreq.csr的文件,你可以将它提交到CA(参考CA网站上的文档怎样做)。然后就得到了证书。
例如:我们申请了个Verisign.com的测试证书保存为:client.cer
3.从你获得证书的CA下载Chain Certificate:
例如:
Verisign.com正式证书:去http://www.verisign.com/support/install/intermediate.html
Verisign Test CA Root证书:去http://www.verisign.com/server2/trial/faq/index.html
4.将Chain Certificate导入到keystore:
例如:导入Verisign Test CA Root证书getcacert.cer
C:\j2sdk1.4.2_05\bin>;keytool -import -trustcacerts -alias root -file getcacert.cer -keystore keystore
输入keystore密码: 12345678
Owner: OU=For VeriSign authorized testing only. No assurances (C)VS1997, OU=www.verisign.com/repository/TestCPS Incorp. By Ref. Liab. LTD., O="VeriSign, Inc"
发照者: OU=For VeriSign authorized testing only. No assurances (C)VS1997, OU=www.verisign.com/repository/TestCPS Incorp. By Ref. Liab. LTD., O="VeriSign, Inc"
序号: 52a9f424da674c9daf4f537852abef6e
有效期间: Sun Jun 07 08:00:00 CST 1998 至: Wed Jun 07 07:59:59 CST 2006
认证指纹:
MD5: 40:06:53:11:FD:B3:3E:88:0A:6F:7D:D1:4E:22:91:87
SHA1: 93:71:C9:EE:57:09:92:5D:0A:8E:FA:02:0B:E2:F5:E6:98:6C:60:DE
信任这个认证? [否]: y
认证已添加至keystore中
查看证书
C:\j2sdk1.4.2_05\bin>;keytool -list -keystore keystore
输入keystore密码: 12345678
Keystore 类型: jks
Keystore 提供者: SUN
您的 keystore 包含 2 输入
root, 2004-11-26, trustedCertEntry,
认证指纹 (MD5): 40:06:53:11:FD:B3:3E:88:0A:6F:7D:D1:4E:22:91:87
tomcat, 2004-11-26, keyEntry,
认证指纹 (MD5): B8:44:A1:A2:C7:9A:09:EE:A0:CF:5B:AA:DC:F7:0F:80
5.最后,导入你的新证书:
C:\j2sdk1.4.2_05\bin>;keytool -import -trustcacerts -alias tomcat -file client.crt -keystore keystore
.old
输入keystore密码: 12345678
认证回复已安装在 keystore中
查看证书
C:\j2sdk1.4.2_05\bin>;keytool -list -keystore keystore
输入keystore密码: 12345678
Keystore 类型: jks
Keystore 提供者: SUN
您的 keystore 包含 2 输入
root, 2004-11-26, trustedCertEntry,
认证指纹 (MD5): 40:06:53:11:FD:B3:3E:88:0A:6F:7D:D1:4E:22:91:87
tomcat, 2004-11-26, keyEntry,
认证指纹 (MD5): 68:33:EE:6C:5C:5B:70:B5:0D:85:3B:6D:AF:00:91:24
注意:仔细观察tomcat项的认证指纹与导入之前是不同的。
6.安装证书
把最后生成的keystore文件,复制到tomcat安装路径的conf目录下
7.修改Tomcat的配置文件server.xml
<!– Define a SSL Coyote HTTP/1.1 Connector on port 8443 –>;
<Connector port=”8443”
maxThreads=”150” minSpareThreads=”25” maxSpareThreads=”75”
enableLookups=”false” disableUploadTimeout=”true”
acceptCount=”100” debug=”0” scheme=”https” secure=”true”
clientAuth=”false” sslProtocol=”TLS”
keystoreFile=”/conf/keystore” keystorePass=”12345678”/>;
8.重新启动Tomcat
9.为IE浏览器安装测试根证书:
双击getcacert.cer,安装测试根证书
10.测试SSL
打开IE输入https://www.test.com:8443/