(首先你要有 ssl 證書 ,我是阿里的 )html
查看申請ssl證書web
(1.)pfx-password.txt 存放 [密碼]apache
(2.)xxxx.pfx 存放 證書tomcat
(3.1) 配置 https(詳情,可能須要先登陸)安全
<Connector port="443"
protocol="org.apache.coyote.http11.Http11Protocol"
SSLEnabled="true"
scheme="https"
secure="true"
keystoreFile="G:/xxxxx/apache-tomcat-7.0.75/cret/xxxxx.pfx"
keystoreType="PKCS12"
keystorePass="CH7T55MI"
clientAuth="false"
SSLProtocol="TLSv1+TLSv1.1+TLSv1.2"
ciphers="TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA256"/>oop
參數信息:編碼
port::端口號url
protocol:協議規則>詳情spa
SSLEnabled:開啓tomcat對https支持(true/false).net
scheme:協議名稱
secure:是否開啓安全訪問(true/false)
keystoreFile:祕鑰文件路徑(即xxxx.pfx 的絕對路徑)
keystoreType:祕鑰庫類型(jks/pkcs12)
keystorePass:建立祕鑰文件時輸入的密碼(即fx-password.txt的內容)
clientAuth:身份驗證(true/false)
SSLProtoco:ssl的協議
ciphers:密碼
(3.2) 配置http
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" URLEncoding="UTF-8"/>
參數信息:
port: 端口號
connectionTimeout: 設置鏈接超時,單位毫秒 (connectionTimeout = 2000;表明超過2秒,就是超時)
protocol:協議規則>詳情
redirectPort:使用http請求某個資源,而該資源自己又被設置了必需要https方式訪問,此時Tomcat會自動重定向到這個redirectPort設置的https端口>詳情
URLEncoding:編碼格式((URL編碼),也稱做百分號編碼)
四.配置全部訪問強制轉換爲 https(選配)
在 tomcat 安裝目錄 conf/web.xml 的</welcome-file-list> 以後
<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>
五.從新啓t動tomcat 便可