tomcat布署https协议
为tomcat服务器生成一个server.jks
jks就是把key和crt文件合在一起,以java key store的形式存诸
使用jdk目录下的keytool工具生成证书
生成jks密钥对
keytool -genkey -alias Nemo-20100613CG509 -keyalg RSA -keysize 1024 -dname "CN=Nemo-
20100613CG,OU=insurance-dart,O=Cognizant,L=SH,S=SH,C=CN" -keypass ****** -keystore Nemo-
20100613CG.jks -storepass ******
生成jks的csr
keytool -certreq -alias Nemo-20100613CG509 -sigalg "MD5withRSA" -file Nemo-20100613CG.csr -
keypass ******-keystore Nemo-20100613CG.jks -storepass ******
使用openssl生成jks的crt
openssl x509 -req -in Nemo-20100613CG.csr -out Nemo-20100613CG.crt -CA ca.crt -CAkey ca.key -
days 3650 -CAcreateserial -sha1 -trustout -CA ca.crt -CAkey ca.key -days 3650 -CAserial ca.srl
-sha1 -trustout
生成符合x509格式的jks
将rootCA导入到jks信任域
keytool -import -alias rootca -trustcacerts -file ca.crt -keystore Nemo-20100613CG.jks -
storepass ******
修改tomcat的server.xml文件
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
改为:
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="C:/Java/apache-tomcat-7.0.2/conf/Nemo-20100613CG.jks"
keystorePass="******"
/>
单向认证
clientAuth="false"
双向认证
clientAuth="true"