Tomcat配置https

來源:互聯網
上載者:User

標籤:too   sed   中間   out   protoc   ref   pac   closed   pass   

軟體列表:

tomcat版本:apache-tomcat-7.0.78-windows-x64.zip

jdk版本:1.8.0_31-b13

1.配置tomcat使用者

開啟tomcat安裝目錄下的conf檔案中的tomcat-users.xml檔案

添加一條新的記錄(注意在“/tomcat-users”中間添加):

使用者必須是tomcat,記錄下密碼後續會用到!!

1 <user password="521xybf" roles="" username="tomcat"/>
插入tomcat使用者代碼

 

2.產生tomcat.keystore

執行cmd,切換到tomcat安裝目錄bin下執行以下命令:

1 keytool -genkeypair -alias "tomcat" -keyalg "RSA" -keystore "f:\tomcat.keystore"  
執行命令

keytool -genkeypair -alias "tomcat" -keyalg "RSA" -keystore "d:\tomcat.keystore"  (最後目錄可修改)

 

 

注意:名字與姓氏填寫的是IP地址,tomcat密鑰口令指的是上步tomcat使用者配置中密碼。

執行完成之後會在對應目錄下組建檔案:

 

 

3.修改tomcat的server.xml,添加tomcat中HTTPS配置

開啟tomcat安裝目錄下的conf檔案中的tomcat-users.xml檔案

1     <Connector port="8080" protocol="HTTP/1.1"2                connectionTimeout="20000"3                redirectPort="8443" />
修改前server.xml配置 
1     <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" SSLEnabled="true"  2               enableLookups="false"3               acceptCount="100" disableUploadTimeout="true"4               maxThreads="150" scheme="https" secure="true"  5               clientAuth="false" sslProtocol="TLS"   6        keystoreFile="D:/JAVA/Tomcat/tomcat.keystore"  7        keystorePass="123456"/>  
修改後server.xml配置

 

keystoreFile為第一步產生的檔案的路徑,密keystorePass為第一步中密鑰庫口令

 

 4.重啟tomcat,訪問項目就能看到https了

訪問地址:注意連接埠號碼8443

https://127.0.0.1:8443/Https/

附件為修改後的server.xml和tomcat-users.xml, 點擊這裡下載。

tomcat下載點擊這裡,JDK下載點擊這裡。

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.