1,cd..%JAVA_HOME%/.bin 为tomcat生成服务端证书命令如下:证书名称为:server.keystore
Keytool -genkey -v -alias tomcat -keyalg RSA -keystore server.keystore
2,为浏览器生成证书,格式为PKCS12,如下命令:
Keytool -genkey -v -alias myKey -keyalg RSA -storetype PKCS12 -keystore my.p12 -dname "CN=localhost,OU=localhost,O=localhost,L=localhost,ST=localhost,C=CN" -storepass yourpassword -keypass yourpassword
3,让服务器信任客户端证书,命令如下:
Keytool -export -alias myKey -keystore my.p12 -storetype PKCS12 -rfc -file my.cer
4,最后一步将my.cer导入到服务器的证书库,添加为一个信任证书,命令如下:
Keytool -import -v -file my.cer -keystore server.keystore
5,tomcat配制文件如下,添加到server.xml文件中:
tomcat\conf\server.xml
<Connector protocol="org.apache.coyote.http11.Http11NioProtocol"
port="8443" minSpareThreads="5" maxSpareThreads="75"
enableLookups="true" disableUploadTimeout="true"
acceptCount="100" maxThreads="200"
scheme="https" secure="true" SSLEnabled="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="D:\Program Files\Apache Software Foundation\Tomcat 7.0\ca\server.keystore"
truststoreFile="D:\Program Files\Apache Software Foundation\Tomcat 7.0\ca\server.keystore"
keystorePass="yourpassword"/>