我剛跑了一些測試,並列出您的CA選擇在ca_certs
參數正是你所需要的。
我試過的系統是Linux和Python 2.6。如果你不使用ca_certs
,它不會讓你使用cert_reqs=ssl.CERT_REQUIRED
:
Traceback (most recent call last):
File "sockettest.py", line 18, in <module>
cert_reqs=ssl.CERT_REQUIRED, ssl_version=ssl.PROTOCOL_TLSv1)
File "/usr/lib/python2.6/ssl.py", line 350, in wrap_socket
suppress_ragged_eofs=suppress_ragged_eofs)
File "/usr/lib/python2.6/ssl.py", line 113, in __init__
cert_reqs, ssl_version, ca_certs)
ssl.SSLError: _ssl.c:317: No root certificates specified for verification of other-side certificates.
我還試圖用一個客戶端發送一個證書從ca_certs
參數CA不是,我也得到ssl_error_unknown_ca_alert
(如預期)。
請注意,無論哪種方式,都不會發送客戶端證書CA列表(位於CertificateRequest
TLS消息的certificate_authorities
列表中),但這不是必需的。只有幫助客戶選擇證書纔有用。
爲什麼?當您嘗試進行身份驗證來完成授權時,通常會出現這種情況。他們不是一回事。 – EJP 2010-10-25 10:24:34
@EJP,如果您不希望'CertificateRequest' TLS消息(請求客戶端證書的那個消息)中的'certificate_authorities'列表包含您不想要的列表(此列表的DN傾向於默認情況下從可用CA的列表填充)。另外,您的系統上可能存在您不信任的默認CA,即使僅用於身份驗證。 – Bruno 2010-10-25 15:37:30
我使用SSL在「封閉」網絡上對客戶端進行身份驗證:我(我的CA)將簽署所有證書,因此沒有理由相信任何其他CA. – 2010-10-25 15:44:40