一、找到bin下的keytool.exe。按住 Shift 键,同时右键点击空白处。执行命令keytool -genkeypair -alias "tomcat" -keyalg "RSA" -keystore "D:\tomcat.keystore"java
二、在Eclipse中Servers\test-https-config\server.xml文件中添加以下代码git
<Connector port="4443" protocol="org.apache.coyote.http11.Http11Protocol" maxThreads="150" SSLEnabled="true" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" keystoreFile="D:\tomcatKeyTool-noUse\tomcat.keystore" keystorePass="123456" />
并修改redirctPort="4443"。web
三、在testHttps\WebContent\WEB-INF\web.xml中添加以下图代码 apache
<security-constraint> <web-resource-collection> <web-resource-name>securedapp</web-resource-name> <url-pattern>/*</url-pattern> </web-resource-collection> <user-data-constraint> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint> </security-constraint>
四、运行效果以下浏览器
五、安装tomcat证书在浏览器中的认证tomcat
keytool -export -alias tomcat -keystore D:\tomcatKeyTool-noUse\tomcat.keystore -file d:\tomcatKeyTool-noUse\tomcat.cer -storepass 123456app
导入到浏览器的证书中url
360浏览器效果以下(谷歌浏览器没起做用不知道为何??)code