2013-05-20 63 views
9

我們希望使用開放SSL使用雙向證書認證。驗證進入SSL使用OpenSSL的S_Server

當我們打開s_server如下,該客戶端能夠連接到我的服務器:

openssl s_server -accept 12345 -cert our-cert.pem 

(我們-cert.pem是我們的證書。)

這工作得很好。然而,我的要求是:

  1. 驗證傳入證書是可信CA有效,並且
  2. 驗證的通用名稱是什麼,我們希望它是。

我已經試過這樣:

openssl s_server -accept 12345 -cert our-cert.pem -CApath /etc/ssl/certs/ 

這允許客戶端進行連接。但我的問題是:

  1. 我怎樣才能確定它是驗證包含SSL是有效的,並由CA頒發?
  2. 如何驗證通用名稱是我期望的?

回答

6

對於服務器,您需要添加「-Verify」選項強制客戶端提供的證書。深度是客戶端證書鏈的最大長度。

這應該照顧的問題#1。

#2,我不知道有一種方法使用這些命令的OpenSSL按通用名稱限制。

你可以看到服務器的OpenSSL文檔/客戶機命令在這裏:

s_server

s_client

4

要測試的CA使用:

/usr/local/ssl/bin/openssl s_server -accept 7569 -cert /opt/GCTI/cert/host1_cert.pem -CAfile /opt/GCTI/cert/ca_cert.pem -key /opt/GCTI/cert/host1_priv_key.pem    

-cert is the public key file for this host 
-key is the private key file for this host 
-CAfile is the CA file, needed for self signed certificate 
-port is the port number to open up 

這將打開監聽端口7569,它將接受指定證書的TLS連接。

如果CA無效,則最後一行看起來像這樣

Verify return code: 21 (unable to verify the first certificate) 

要連接到該服務器,全面的端到端測試(不是真的問的問題)

openssl s_client -showcerts -connect host1:7569 -CAfile /opt/GCTI/cert/ca_cert.pem 

將host1替換爲您的實際主機。這將驗證TLS的服務是有效的,並通過運行同一個CA簽署的證書