近期使用了一段开源的python脚本,脚本中使用了urllib2来作为HTTP客户端,在访问https站点时报下面的错误:
First request to SP failed: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] cert
ificate verify failed (_ssl.c:726)>
代码如下:
# create a cookie jar and cookie handler
cookie_jar = cookielib.LWPCookieJar()
cookie_handler = urllib2.HTTPCookieProcessor(cookie_jar)
# need an instance of HTTPS handler to do HTTPS
httpsHandler = urllib2.HTTPSHandler(debuglevel = 0)
if debug:
httpsHandler.set_http_debuglevel(1)
# create the base opener object
opener = urllib2.build_opener(cookie_handler, httpsHandler)
# headers needed to indicate to the SP an ECP request
headers = {
'Accept' : 'text/html; application/vnd.paos+xml',
'PAOS' : 'ver="urn:liberty:paos:2003-08";"urn:oasis:names:tc:SAML:2.0:profiles:SS