tomcat中配置https
在tomcat中的conf/server.xml中添加如下代码:
>Connector port="443" maxThreads="200" scheme="https" secure="true" SSLEnabled="true" keystoreFile="/usr/local/tomcat7/ssl/tomcat.keystore" keystorePass="123456" clientAuth="false" sslProtocol="TLS"/<
其中,keystoreFile是由crt和key生成的keyStore文件所在的路径,keystorePass是生成该文件时输入的密码。
tomcat配置http转https
修改server.xml,将80端口重定向到443端口:
>Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="443" /<
而后在web.xml最后添加如下代码(在之前):
>security-constraint< >web-resource-collection < >web-resource-name /web-resource-name< >url-pattern/url-pattern< >/web-resource-collection< >user-data-constraint< >transport-guarantee/transport-guarantee< >/user-data-constraint< >/security-constraint<
然后访问http://domain.com及https://domain.com验证是否成功
来源:博客园
作者:徐一钉新浪博客
链接:https://www.cnblogs.com/xuyiding/p/11629111.html