-
生成 key
# $JAVA_HOME/bin/keytool \ -genkeypair \ -keyalg RSA \ -keysize 2048 \ -keystore tomcat.jks \ -alias tomcat \ -storepass yourpass \ -keypass yourpass \ -dname "CN=YourName, OU=YourOrg, O=Your Company, L=YourCity, S=YourState, C=CN"
特别说明:上边输入的“-storepass”和“-keypass“ 2个密码一定要相同,否则TOMCAT起不来。
参考:
-
然后将生成的 tomcat.jks 文件 copy 到 $CATALINA_BASE/conf 目录
-
编辑 $CATALINA_BASE/conf/server.xml
打开下面的配置
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" keystoreFile="./conf/tomcat.jks" keystoreType="JKS" keystorePass="yourpass" ciphers="TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA" />
- keystoreFile: 就是刚才创建的证书文件,这里使用的是相对目录,也就是tomcat根目录.
- keystorePass: 是你创建证书时输入的密码.
- ciphers: 用来解决 chrome 45+ ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY 问题(http://stackoverflow.com/questions/30931692/diffie-hellman-public-key-error-with-tomcat-7)
-
启动 Tomcat
来源:oschina
链接:https://my.oschina.net/u/870897/blog/305230