https環境搭建配置(伺服器基於tomcat)

來源:互聯網
上載者:User

標籤:style   http   color   io   os   ar   使用   strong   sp   

1、產生服務端認證庫(keystore認證庫檔案),用於用戶端驗證服務端的真實性

keytool -genkey -v -alias key_server -keyalg RSA -keystore e:\server.keystore -dname "CN=D-F005227,OU=youku,O=zhibohudong,L=beijing,ST=beijing,C=cn" -storepass Aa123 -keypass Aa123 -validity 36000


頒發者資訊:

CN : 一般指本網站網域名稱(communicating net)

OU : 組織單位名稱(organization unit)

O : 組織名稱(organization)

L : 城市或地區(location)

ST : 州或省份(state)

C : 兩字母國家代碼(country)


2、產生用戶端認證(PKCS12檔案),用於雙向認證中服務端驗證用戶端請求來源是否合法使用者

keytool -genkey -v -alias key_client -keyalg RSA -storetype PKCS12 -keystore e:\client.p12 -dname "CN=D-F005227,OU=youku,O=zhibohudong,L=beijing,ST=beijing,C=cn" -storepass Bb123 -keypass Bb123 -validity 36000


3、讓服務端信任用戶端認證,將用戶端認證匯出為CER檔案

keytool -export -alias key_client -keystore e:\client.p12 -storetype PKCS12 -storepass Bb123 -rfc -file e:\client.cer


4、將step 3中匯出的用戶端認證(CER檔案)匯入到step 1中的服務端認證庫中,以完成信任綁定

keytool -import -v -file e:\client.cer -keystore e:\server.keystore -storepass Aa123


5、Tomcat伺服器配置,支援https安全連線(SSL雙向驗證,clientAuth=true|false|want)

開啟TOMCAT_HOME\conf\server.xml,在<Service name="Catalina">下新增:

  <Connector port="4433" protocol="HTTP/1.1" SSLEnabled="true"     maxThreads="150" scheme="https" secure="true" clientAuth="true"     sslProtocol="TLS" keystoreFile="e:/server.keystore" keystorePass="Aa123"     truststoreFile="e:/server.keystore" truststorePass="Aa123"/>

6、讓用戶端匯入認證,以便完成雙向認證,正常訪問

call e:/client.p12


7、匯出服務端認證,安裝在用戶端(憑證存放區位置:授信任的根授權),以便建立信任連接,保證用戶端不會提示不信任的網站(如果服務端認證是經權威認證機構頒發,則無須執行該步驟)

keytool -export -alias key_server -keystore e:\server.keystore -storepass Aa123 -rfc -file e:\server.cercall e:/server.cer


8、啟動伺服器,訪問驗證

輸入地址:https://d-f005227:4433,可愛的湯姆小貓出現了,且地址欄前面出現一把綠色的鎖,OK,打完收工!



附:在開啟雙向SSL認證(clientAuth=true)時,使用Firefox瀏覽器訪問會提示

這時需要手動按以下步驟匯入用戶端認證:

菜單 --> 工具 --> 選項 --> 進階 --> 認證 --> 查看認證 --> 您的認證 --> 匯入 --> 選擇client.p12 --> 輸入用戶端認證密鑰 --> 提示匯入成功 --> 確定 --> 重新整理頁面 --> over

https環境搭建配置(伺服器基於tomcat)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.