天天看點

tomcat搭建 https雙向認證

           SSL(Secure Sockets Layer 安全套接層)協定,及其繼任者TLS(Transport Layer Security傳輸層安全)協定,是為網絡通信提供安全及資料完整性的一種安全協定。TLS與SSL在傳輸層對網絡連接配接進行加密,用于保障網絡資料傳輸安全,利用資料加密技術,確定資料在網絡傳輸過程中不會被截取及竊聽。SSL協定已成為全球化标準,所有主要的浏覽器和WEB伺服器程式都支援SSL協定,可通過安裝SSL證書激活SSL協定。

SSL協定提供的服務主要有:

1.認證使用者和伺服器,確定資料發送到正确的客戶機和伺服器;

2.加密資料以防止資料中途被竊取;

3.維護資料的完整性,確定資料在傳輸過程中不被改變。

第一  建立伺服器密鑰

keytool -genkey -v -alias serverKey -dname "CN=localhost" -keyalg RSA -keypass 123456 -keystore server.keystore -storepass 123456
           

       第二  建立用戶端密鑰  . p12,注意這個密鑰庫的字尾名,注意密鑰庫類型PKCS12

keytool -genkey -v -alias clientKey -dname "CN=SomeOne" -keyalg RSA -keypass 123456 -keystore client.p12 -storepass 123456 -storetype PKCS12
           

      第三  客服端密鑰導出證書檔案 .cer

keytool -export -alias clientKey -file clientKey.cer -keystore client.p12 -storepass 123456 -storetype PKCS12
           

     第三  把客服端的證書導入 伺服器證書庫,并設定為信任 yes

keytool -import -v -alias clientKey -file clientKey.cer -keystore server.keystore -storepass 123456
           

    第五   輕按兩下client.p12  證書向導 

1.導入的檔案client.p12

2.為私鑰鍵入密碼123456,勾選:标志此密鑰為可導出的

3.證書存儲,選:将所有的證書放入下列存儲區,然後,浏覽-個人

最後配置tomcat   conf檔案 server.xml檔案

<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
        maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
        sslProtocol="TLS" clientAuth="true"   keystoreFile="conf/server.keystore" keystorePass="123456"
	truststoreFile="conf/server.keystore" truststorePass="123456"
    />
           
tomcat搭建 https雙向認證

繼續閱讀