tomcat https访问部署

tomcat https访问部署

1.自签名证书

利用java命令生成自定义签名证书

keytool -genkey -alias tomcat -keypass 123456 -keyalg "RSA" -keystore "e:\tomcat.keystore"
//可执行后输入
-storepass 123456

2. tomcat 服务器修改server.xml

将8443端口注释放出来 (默认是8443 但是https请求需要带端口号,改成443端口便不用带端口号访问)

3.tomcat https访问部署

<Connector port="443" protocol="org.apache.coyote.http11.Http11Protocol"
      maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
      clientAuth="false" sslProtocol="TLS"
      keystoreFile="E:\tomcat.keystore"
      keystorePass="123456"/>

4.将 http请求重定向到https

修改conf.xml
tomcat https访问部署

  <Connector port="8080" protocol="HTTP/1.1"
              connectionTimeout="20000"
              redirectPort="443" />

5. 配置web.xml

  <login-config>    
    <!-- Authorization setting for SSL -->    
    <auth-method>CLIENT-CERT</auth-method>    
    <realm-name>Client Cert Users-only Area</realm-name>    
  </login-config>    
  <security-constraint>    
    <!-- Authorization setting for SSL -->    
    <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请求的
posted @ 2021-06-21 15:26  易阳羽之灵异  阅读(107)  评论(0编辑  收藏  举报