2009年11月29日 星期日

Tomcat上設定SSL雙向驗證

1. 在Server.xml裡SSL的Connector tag內加入clientAuth="true"這個屬性,此屬性表示所有走SSL的Client都需驗證它的憑證是否為Server所信任的。
<Connector port="4443" minSpareThreads="5" maxSpareThreads="475" enableLookups="true"
 disableUploadTimeout="true" acceptCount="500" maxThreads="1000" scheme="https"
 secure="true" SSLEnabled="true" keystoreFile="/.keystore"
 keystorePass="admin123" sslProtocol="TLS" URIEncoding="UTF-8" clientAuth="true"
 truststoreFile="/.keystore" truststorePass="admin123" truststoreType="JKS" />
        PS. JKS為Java Key Store,也可以用另一種類型PKCS12

2. 若在Server.xml無設定truststoreFile屬性等相關資訊時,則Client只要使用任何正確的憑證即可進入網頁。

3. 若要限定Client的憑證是特定CA所發出的憑證,則需要設定truststoreFile屬性等相關資訊。並將所信任的CA的憑證,利用keytool匯入到truststoreFile(此範例為.keystore)。


沒有留言:

張貼留言