Tomcat9 的https设置

  1. https://freessl.org 网站上申请免费https证书

  2. 证书为pem和key文件,然后用转换工具转成jks文件,工具地址:
    https://myssl.com/cert_convert.html

  3. tomcat 的server.xml 文件

<Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol"
               maxThreads="150" SSLEnabled="true">
        <SSLHostConfig>
            <Certificate certificateKeystoreFile="/home/www.test.com.jks" 
                                   certificateKeyAlias="www.test.com"
                                  certificateKeystorePassword="123456"
                         type="RSA" />
        </SSLHostConfig>
    </Connector>

4 tomcat 的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>

猜你喜欢

转载自blog.csdn.net/lsw1124/article/details/81905253