zoukankan      html  css  js  c++  java
  • http和https支持

    请求方式支持http和https:

    1.生成证书

      keytool -genkey -alias tomcat -keyalg RSA -keystore E:kaifaapache-tomcat-6.0.35 omcat.keystore -validity 36500

      其中-validity 36500表示证书有效期,100年,默认是90天;-keystore E:kaifaapache-tomcat-6.0.35 omcat.keystore表示存放证书的路径

      将上面的命令在cmd中执行,姓氏和名字特别重要(访问的域名,一般输入ip),记下密码,其他的随意输入,

      --遇到的问题:生成证书时若是姓氏和名字输入错误,删除证书就可以了,

    2.配置server.xml

      将配置文件中的<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"   maxThreads="150" scheme="https" secure="true"  clientAuth="false" sslProtocol="TLS" />注释去掉,更改为

    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true"  clientAuth="false" keystoreFile="E:kaifaapache-tomcat-6.0.35 omcat.keystore" 
    keystorePass="123456" sslProtocol="TLS" useBodyEncodingForURI="true" URIEncoding="utf-8"/>

    其中keystoreFile="E:kaifaapache-tomcat-6.0.35 omcat.keystore" 表示文件存放路径,keystorePass="123456"表示证书的密码

    --遇到的问题:配置完成后报错 Socket bind failed: [730048] ?????????×???(Э?é/???????/???)????í?? 试了网上说的吧8443的进程杀掉,但是发现你每次重启后还是这个错误,https://blog.csdn.net/gane_cheng/article/details/53001846在这篇博客中找到解决方法  <!--<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />-->将这一行注释掉

    3.配置tomcat下的conf/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>

    重启tomcat,则可以自动跳转到从http://跳转到https://     http://127.0.0.1:8101/inte -->https://127.0.0.1:8443/inte

    若是要省略端口则配置http访问端口为80,https访问端口为443,访问http:127.0.0.1/inte自动跳转到https://127.0.0.1/inte

  • 相关阅读:
    [FlareOn4]greek_to_me
    [FlareOn1]Sploitastic
    [FlareOn1]Creation
    [FlareOn1]5get_it
    esxi6.7中,显卡设置为直通步骤
    esxi6.7安装步骤
    nmcli命令详解
    查看指定进程的IO/CPU/MEM/带宽/显卡
    使用WSGIServer修改静态文件
    k8s配置多端口ingress
  • 原文地址:https://www.cnblogs.com/hqsbrx/p/9453724.html
Copyright © 2011-2022 走看看