tomcat啓用https協議配置過程(有案例)

一、找到bin下的keytool.exe。按住 Shift 鍵,同時右鍵點擊空白處。執行命令keytool -genkeypair -alias "tomcat" -keyalg "RSA" -keystore "D:\tomcat.keystore"java

二、在Eclipse中Servers\test-https-config\server.xml文件中添加以下代碼git

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

並修改redirctPort="4443"。web

三、在testHttps\WebContent\WEB-INF\web.xml中添加以下圖代碼 apache

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

四、運行效果以下瀏覽器

五、安裝tomcat證書在瀏覽器中的認證tomcat

keytool -export -alias tomcat -keystore D:\tomcatKeyTool-noUse\tomcat.keystore -file d:\tomcatKeyTool-noUse\tomcat.cer -storepass 123456app

導入到瀏覽器的證書中url

360瀏覽器效果以下(谷歌瀏覽器沒起做用不知道爲何??)code

源碼地址https://gitee.com/893093993/testHttps.gitserver

相關文章
相關標籤/搜索