前言:https协议配置,一般用于针对政府部门的终端有网络防火墙、网络过滤器等,使系统中的一些请求被拦截(劫持),原因一般为在请求头中有存在敏感信息,被网络过滤的监听器发现即拦截,可能会造成强退、强制刷新等现象;改为https协议后,请求里的通讯信息进行过加密处理,进而不会被拦截。


配置方法:三步即可完成,没时间解释了快上车;


1.生成SSL协议证书

keytool -genkeypair -alias "tomcat" -keyalg "RSA" -keystore "G:\test.keystore"

https协议配置_tomcat配置


2. 更改tomcat配置文件(server.xml),以我本机路径为例(如下图):

https协议配置_https_02

a.修改配置文件第一处:

https协议配置_tomcat配置_03

b. 修改配置文件第二处:

https协议配置_tomcat配置_04

https协议:

<Connector port="4005" protocol="HTTP/1.1" SSLEnabled="true"

maxThreads="150" scheme="https" secure="true"

clientAuth="false" sslProtocol="TLS"

keystoreFile="D:\tomcat\apache-tomcat-7.0.79\bin\test.keystore" keystorePass="123456" URIEncoding="utf-8"/>

http协议:

<Connector port="4006" protocol="HTTP/1.1"

connectionTimeout="20000"

redirectPort="8445" URIEncoding="utf-8"/>
————————————————


  1. 第三步:修改java web项目的web.xml配置文件(如下图)
<!-- 初始化https协议 -->
<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>
————————————————


https协议配置_配置文件_05


https配置完成,访问路径​​https://localhost:XXXX/XXX​