Tomcat https(SSL) 简单的证书配置

参考[url]http://confluence.atlassian.com/display/JIRA/Running+JIRA+over+SSL+or+HTTPS#RunningJIRAoverSSLorHTTPS-ImportCertificateIntoTheTruststore[/url],这个是配jira,但是差不多。

因为正式的CA申请要填什么东西,还要钱,很麻烦,如果我们只想在开发环境测试, 只要一个测试的证书用用就可以了,很多网上的sample不够详细,我记录下自己的研究。

我们一开始做的证书,用IE7访问的时候总是有个error, 看起来不舒服。后面解决这两个问题。

Windows环境,在CMD下输入
1.
"%JAVA_HOME\bin\keytool" -genkey -alias tomcat -keyalg RSA

当你敲入以上命令后, CMD提示输入
[quote]What is your first and last name?[/quote]
这时候,你[b]必须[/b]填写server ip或域名, 不是随便写的,否则后面生成的证书在IE7访问的时候, 会报一个"Mismatch Address"的Error.
后面的提示填的Unit, Dept, Country随便写写都无所谓的。
Tomcat默认的password是changeit,如果你写别的,在server.xml就要加入
keystorePass="xx"

完了后,会生成文件[quote]C:\Documents and Settings\xx\keystore[/quote]

2.
"%JAVA_HOME\bin\keytool" -export -alias tomcat -file file.cer

根据keystore信息生成一个证书

3.
"%JAVA_HOME\bin\keytool" -import -alias tomcat -file file.cer -keystore "%JAVA_HOME%\jre\lib\security\cacerts"

讲生成的证书file.cer导入到Server JDK cacerts中。这个该死证书好像只能导入一次,重复导, 回报alias tomcat existed的错误。。

接下来是tomcat目录的server.xml配置
<Connector port="8443" minProcessors="5" maxProcessors="75" 
enableLookups="true" disableUploadTimeout="true"
acceptCount="100" debug="0" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />

加入上面这段, 相当的简单, 因为都是默认的路径和P[img][/img]assword, 所以没加[quote]keystoreFile="xx" keystorePass="xx"[/quote]

最后在浏览器certification需要安装到IE7,安装到"Trusted Root Certfication ..."
[img]http://dl.iteye.com/upload/picture/pic/56309/ef4ede52-13de-3d39-89a0-8e97519288c1.png[/img]

访问https://xxIp/xxApp 就可以了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值