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),访问如下图
如果想继续访问,点击高级,继续访问即可,如图: