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>