JavaWeb網站建立安全鏈接

JavaWeb項目配置https安全鏈接

這裏寫圖片描述

如圖第一步:

會在用戶目錄下生成一個文件: .keystore

如圖第五步:

在Tomcat的配置文件server.xml中加入標籤

<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
            maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
            clientAuth="false" sslProtocol="TLS" keystoreFile="C:/Users/Administrator/.keystore(祕鑰文件.keystore的路徑)"
            keystorePass="(祕鑰文件密碼)"/>

若想強制瀏覽器鏈接爲https,需要在web項目的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>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章