2010-08-30 167 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