1.找到自己tomcat安裝文件,訪問apache-tomcat-7.0.67\conf\server.xml文件,打開server.xml文件,將如下注釋代碼釋放
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->
並添加在第三行添加 代碼: keystoreFile="${user.home}/.keystore" keystorePass="changeit"
結果如下:
<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
keystoreFile="${user.home}/.keystore" keystorePass="changeit"
clientAuth="false" sslProtocol="TLS" />
2.打開terminal,利用命令行進入到apache-tomcat-7.0.67\conf 文件下,輸入命令行 keytool -help 如下圖:
(該命令行執行的是jdk中keytool.exe文件)
3.生成祕鑰對,輸入命令行 keytool -genkeypair -help ,如下圖:
4.執行命令 keytool -genkeypair -alias test -keyalg RSA -validity 3650 -keystore test.keystore 如下圖:
逐一輸入祕鑰庫口令等信息:
5.訪問apache-tomcat-7.0.67\conf 文件下會發現,創建了test.keystore文件,如圖:
6.將生成的 test.keystore文件綁定到server.xml中,結果如下:
<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
keystoreFile="conf\test.keystore" keystorePass="123456"
clientAuth="false" sslProtocol="TLS" />
7.重新啓動服務器(重啓tomcat),訪問如下圖
如果想繼續訪問,點擊高級,繼續訪問即可,如圖: