tomcat配置https

來源:互聯網
上載者:User

標籤:http   tomcat   cti   prot   org   fonts   url   enabled   sni   

1.產生keystore檔案。keytool -v -genkey -alias tomcat -keyalg RSA -keystore  d:/tomcat.keystore -validity 36500

這裡的keytool在jdk的bin目錄下,也可以寫絕對位址,這裡的口令一律寫123456,下面要用到


這樣就產生了tomcat.keystore


2、修改  tomcat/conf/server.xml ,並指定安全性憑證位置和密碼

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


此時是http和https都可以訪問項目的,若要完全禁用http則需要修改以下

8080和8009(這裡的連接埠改為了8003)對應改為443

 <Connector port="8080" protocol="HTTP/1.1"                connectionTimeout="20000"                redirectPort="443" /><!-- Define an AJP 1.3 Connector on port 8009 -->    <Connector port="8003" protocol="AJP/1.3" redirectPort="443" />



3.配置web.xm,在welcome-file-list後面加上以下

 <welcome-file-list>        <welcome-file>index.html</welcome-file>        <welcome-file>index.htm</welcome-file>        <welcome-file>index.jsp</welcome-file>    </welcome-file-list><login-config><!--Authorization setting for SSL --><auth-method>CLIENT-CERT</auth-method><realm-name>Client Cert User-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>

若要禁用掉http不安全方法,這裡的配置可以這樣寫

 <welcome-file-list>        <welcome-file>index.html</welcome-file>        <welcome-file>index.htm</welcome-file>        <welcome-file>index.jsp</welcome-file>    </welcome-file-list><login-config><!--Authorization setting for SSL --><auth-method>CLIENT-CERT</auth-method><realm-name>Client Cert User-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>    <security-constraint><web-resource-collection><web-resource-name>fortune</web-resource-name><url-pattern>/*</url-pattern><http-method>PUT</http-method><http-method>DELETE</http-method><http-method>HEAD</http-method><http-method>OPTIONS</http-method><http-method>TRACE</http-method></web-resource-collection><auth-constraint></auth-constraint>    </security-constraint>



4.附加元件目,啟動後匯入認證就可以了

訪問https://localhost:443/spfxzd會出現安全性憑證有問題,右鍵









認證--詳細資料--複製到檔案--下一步--一直到匯出檔案到案頭檔案為tomcat.cer

這裡可以雙擊認證安裝下

下面開啟瀏覽器的Internet選項  ----> 內容  ----> 認證


選擇"可信任的根憑證授權單位"  ----> 匯入認證


將產生的認證匯入進來


完成

參考配置:http://www.cnblogs.com/wanghaoyuhappy/p/5267702.html

tomcat配置https

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.