wangbodang

tomcat配置ssl证书

1.server.xml  打开已经注释掉的代码 然后添加证书地址

<Connector SSLEnabled="true" clientAuth="want" keystoreFile="D:\mywork\apache-tomcat-8080\conf\h1024.jks" keystorePass="" keystoreType="JKS" maxThreads="150" port="8443" protocol="org.apache.coyote.http11.Http11Protocol" scheme="https" secure="true" sslProtocol="TLS" truststoreFile="D:\mywork\apache-tomcat-8080\conf\cacerts" truststorePass="" truststoreType="JKS"/>

2.在项目中web.xml中添加配置

<security-constraint>
   <web-resource-collection>
   <web-resource-name>SSL Resource</web-resource-name>
   <url-pattern>/*</url-pattern>
   </web-resource-collection>
   <user-data-constraint>
   <transport-guarantee>CONFIDENTIAL</transport-guarantee>
   </user-data-constraint>
</security-constraint>

这样当我们使用http访问自己的项目时 tomcat会给你自动转变成https

 

分类:

技术点:

相关文章:

  • 2021-11-27
  • 2021-07-12
  • 2021-07-17
  • 2021-12-28
  • 2021-07-30
  • 2021-09-15
  • 2021-11-30
  • 2021-12-03
猜你喜欢
  • 2021-09-14
  • 2022-02-04
  • 2021-11-19
  • 2021-07-10
  • 2022-12-23
  • 2022-01-15
  • 2022-01-07
相关资源
相似解决方案