龙空技术网

记录tomcat配置https

web全栈程序猿 168

前言:

今天同学们对“tomcat6配置https”大概比较关心,姐妹们都需要了解一些“tomcat6配置https”的相关内容。那么小编同时在网摘上收集了一些关于“tomcat6配置https””的相关知识,希望兄弟们能喜欢,同学们一起来了解一下吧!

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 >SSL</web-resource-name> <url-pattern>/*</url-pattern> </web-resource-collection> <user-data-constraint> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint> </security-constraint>

然后访问及验证是否成功

标签: #tomcat6配置https