1、jdk目录下,使用命令生成证书
keytool -genkeypair -alias "tomcat" -keyalg "RSA" -keystore "d:\tomcat.keystore"
只需要输入2次密码,其他回车即可
2、tomcat/conf/server.xml
追加443这一段代码
<!-- <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true" clientAuth="false"
sslProtocol="TLS" /> -->
<!--追加代码-->
<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="d:\tomcat.keystore"
keystorePass="123456" />
<!--追加代码-->
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>
3、启动tomcat,输入https://localhost:443
提示需要证书,到此完成