说明
最近软件安全要求越来越严,升级http为https,新项目spring boot开发,使用内嵌tomcat,独立tomcat配置研究了下,记录一下。
分享
- 大数据博客列表
- 开发记录汇总
- 个人java工具库 项目https://gitee.com/wangzonghui/object-tool
- 包含json、string、集合、excel、zip压缩、pdf、bytes、http等多种工具,欢迎使用。
开启https服务
添加认证文件
- 将jks认证文件复制到tomcat的
conf
目录下
修改配置
- 修改文件
conf\server.xml
,内容如下:
<Connector port="https端口" protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" keystoreFile="conf/jks文件" keystorePass="密码" >
</Connector>
说明
此模式下http和https服务同时存在。
http转发https
配置https映射端口
- 修改文件
conf\server.xml
,将redirectPort
端口改为https端口
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="https端口" />
配置http服务关闭
- 修改文件
conf\web.xml
,文件最后</web-app>
前增加如下内容:
<login-config>
<auth-method>CLIENT-CERT</auth-method>
<realm-name>Client Cert Users-only Area</realm-name>
</login-config>
<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>
总结
- 最近要求框架用最新版,达到安全扫描要求,这是追着人进步。
- 精通one,学习another,关注next