一、让tomcat支持https请求需要进行如下设置:
1. 生成证书
2. 应用证书到Tomcat
3. 将tomcat的http请求自动转向https。
二、详细设置:
1.沃通(https://buy.wosign.com)上购买一个证书,解压得到jks证书.
2.应用证书到Tomcat
修改conf/server.xml文件
1) 取消注释并修改为:
<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" keystoreFile=”${FilePath}” keystorePass=”密码” />
2) 修改http转发到https的端口
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443" />
3.将tomcat的http请求自动转向https
修改conf/web.xml文件
添加如下片段:
<security-constraint>
<web-resource-collection>
<web-resource-name>Entire Application</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
1. 生成证书
2. 应用证书到Tomcat
3. 将tomcat的http请求自动转向https。
二、详细设置:
1.沃通(https://buy.wosign.com)上购买一个证书,解压得到jks证书.
2.应用证书到Tomcat
修改conf/server.xml文件
1) 取消注释并修改为:
<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" keystoreFile=”${FilePath}” keystorePass=”密码” />
2) 修改http转发到https的端口
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443" />
3.将tomcat的http请求自动转向https
修改conf/web.xml文件
添加如下片段:
<security-constraint>
<web-resource-collection>
<web-resource-name>Entire Application</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>