2010-08-30 145 views
3

我想通過HTTPS訪問Web服務。使用Python驗證證書

我已獲得客戶端證書(p12文件)以訪問它。 以前我們使用的是基本認證。

使用python我不確定如何訪問它。

我想使用httplib2的

h = Http() 
#h.add_credentials("testuser", "testpass") 
#h.add_certificate(keyfile, certfile, '') 
resp, content = h.request("https://example.com/webservice", "POST", xml_data) 
print content 

現在,我很新的SSL,我可以叫add_cert或somethign相似,並給它的P12文件。 我是否需要將其轉換爲PEM文件?

回答

2

的回答我的問題是我的問題

h.add_certificate(keyfile, certfile, '') 

我有一個PKCS12文件,我只是需要把解壓出來從P12文件的密鑰和證書。

openssl pkcs12 -in file.p12 -out key.pem -nodes -nocerts 
openssl pkcs12 -in file.p12 -out cert.pem -nodes -nokeys