import httplib import urllib2 PEM_FILE = './client-000410010.pem' CLIENT_CERT_FILE = './client-000410010.p12' class HTTPSClientAuthHandler(urllib2.HTTPSHandler): def __init__(self, key, cert): urllib2.HTTPSHandler.__init__(self) self.key = key self.cert = cert def https_open(self, req): # Rather than pass in a reference to a connection class, we pass in # a reference to a function which, for all intents and purposes, # will behave as a constructor return self.do_open(self.getConnection, req) def getConnection(self, host): return httplib.HTTPSConnection(host, key_file=self.key, cert_file=self.cert) cert_handler = HTTPSClientAuthHandler(PEM_FILE, CLIENT_CERT_FILE) opener = urllib2.build_opener(cert_handler) urllib2.install_opener(opener) f = urllib2.urlopen("https://10.10.10.10") print f.code
上記のコードを実行したら、'timeout'のエラーが出ました、
分かる方がいますか、
よろしくお願いします。
TypeError: getConnection() got an unexpected keyword argument 'timeout'
利用されているPythonのバージョンはいくつですか?古すぎてサポートできないかも。 https://docs.python.org/ja/2.7/library/httplib.html#httplib.HTTPSConnection
あなたの回答
tips
プレビュー