I'm trying to use urllib2 to open a web page using personal digital certificate.
Actually by command line mode, using "curl -k", is possible to open this resource.
So my question is:
1) Is possible to open this web page using urllib2 bypassing the use of personal digital certificate?
2) If the option (1) is not possible, how can access this resource using urllib2 and "personal digital certificate".
P.S. the code I'm trying to use in order to access this resource is the following:
class HTTPSClientAuthHandler(urllib2.HTTPSHandler):
def init(self, key, cert):
urllib2.HTTPSHandler.init(self)
self.key = key
self.cert = cert
def https_open(self, req):
return self.do_open(self.getConnection, req)
def getConnection(self, host, timeout=300):
return httplib.HTTPSConnection(host, key_file=self.key, cert_file=self.cert)
opener = urllib2.build_opener(HTTPSClientAuthHandler('/Users/antonio/.globus/userkey.pem','/Users/antonio/.globus/usercert.pem') )
response = opener.open("https://........")
print response.read()
The error I got is:
Traceback (most recent call last):
File "HTTPSClientAuthHandler.py", line 18, in
response = opener.open("https://cmsweb.cern.ch/tier0/express_config")
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 389, in open
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 502, in http_response
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 427, in error
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 361, in _call_chain
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 510, in http_error_default
urllib2.HTTPError: HTTP Error 500: Internal Server Error