本地https證書生成步驟
keytool -genkey -v -alias tonguas -validity 3650 -keyalg RSA -keypass ucap123 -storepass ucap123 -keystore tonguas.keystore
步驟二:匯出證書
keytool -export -alias tonguas -keystore tonguas.keystore -file tonguas.cer -storepass changeit
步驟三:客戶端配置:為客戶端的JVM匯入金鑰(將伺服器下發的證書匯入到JVM中)
keytool -import -trustcacerts -alias tonguas -keystore "$JAVA_HOME/jre/lib/security/cacerts" -file tonguas.cer -storepass changeit
步驟四:配置Tomcat SSL
修改server.xml中的SSL服務
Window :
<Connector port="8443" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" keystoreFile="d:/my.keystore" keystorePass="changeit"/>
Linux:
<Connector port="8443" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" keystoreFile="~/my.keystore" keystorePass="changeit"/>