python怎么发SSL认证,在发https报文时报错,求大神指导

wood_auna 2016-09-10 11:04:33

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)

有大神遇到过吗?
...全文
392 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
屎克螂 2016-09-11
  • 打赏
  • 举报
回复
response = requests.request("POST", url, data=payload, headers=headers, verify=False)

37,720

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧