import httplib, urllib, urllib2
test_data = {"userName": "wood_auna", "password": "Auna@12345"}
test_data_urlencode = urllib.urlencode(test_data)
requrl = "https://10.162.48.136:18002/"
req = urllib2.Request(url = requrl, data = test_data_urlencode)
req.add_header('Content-Type', 'application/json')
res_data = urllib2.urlopen(req)
res = res_data.read()
print '[recv:]' + res
结果报错:
res_data = urllib2.urlopen(req)
File "F:\eclipse\test\lib\jython-2.7b2.jar\Lib\urllib2.py", line 127, in urlopen
File "F:\eclipse\test\lib\jython-2.7b2.jar\Lib\urllib2.py", line 404, in open
File "F:\eclipse\test\lib\jython-2.7b2.jar\Lib\urllib2.py", line 421, in _open
File "F:\eclipse\test\lib\jython-2.7b2.jar\Lib\urllib2.py", line 382, in _call_chain
File "F:\eclipse\test\lib\jython-2.7b2.jar\Lib\urllib2.py", line 1222, in https_open
File "F:\eclipse\test\lib\jython-2.7b2.jar\Lib\urllib2.py", line 1184, in do_open
urllib2.URLError: <urlopen error [Errno -1] SSL handshake exception: Differences between the SSL socket behaviour of cpython vs. jython are explained on the wiki: http://wiki.python.org/jython/NewSocketModule#SSL_Support>
然后我用了requersts库,
response = requests.request("POST", url, data=payload, headers=headers)
也报错
requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)
有大神遇到过吗?