注:在tomcat7中验证通过。
在app的web.xml文件中加入如下声明:
<security-constraint>
<web-resource-collection><web-resource-name>my-secure-app</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
Tomcat server.xml配置文件中添加对https的支持:
参考:http://blog.csdn.net/zxygww/article/details/46653213。
步骤:
1、使用JDK自带的证书生成工具,生成证书。
keytool -genkeypair -alias "tomcat" -keyalg "RSA" -keystore "G:\tomcat.keystore"
2、在tomcat安装目录下的conf/server.xml文件中添加Connector。
<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="G:\tomcat.keystore"
keystorePass="123456"
/>
3、使用浏览器打开https://host:8443/,并选择接收证书即可访问https连接。