Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/347.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用;tornado.httpclient“;取回;PostHTTPS";网站获取“;HTTPError:http599";_Python_Httpclient_Httprequest_Tornado_Urllib - Fatal编程技术网

Python 使用;tornado.httpclient“;取回;PostHTTPS";网站获取“;HTTPError:http599";

Python 使用;tornado.httpclient“;取回;PostHTTPS";网站获取“;HTTPError:http599";,python,httpclient,httprequest,tornado,urllib,Python,Httpclient,Httprequest,Tornado,Urllib,我想使用“tornado.httpclient.asynchtpclient”向“https”网站发送“POST”请求,但得到: HTTPError: HTTP 599: [Errno 1] _ssl.c:503: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed 当我改用“urllib”时(使用相同的url和参数,标题我不知道)它就可以工作了 代码如下: url = r'ht

我想使用“tornado.httpclient.asynchtpclient”向“https”网站发送“POST”请求,但得到:

HTTPError: HTTP 599: [Errno 1] _ssl.c:503: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed  
当我改用“urllib”时(使用相同的url和参数,标题我不知道)它就可以工作了
代码如下:

url = r'https://**********.com/****/'
request = tornado.httpclient.HTTPRequest(url = url, method = 'POST', body = body, headers = headers)
client = tornado.httpclient.AsyncHTTPClient()
client.fetch(request, callback = on_reqeust)
tornado.ioloop.IOLoop.instance().start()
生成http请求时添加“验证\证书=错误”
而且似乎没有必要使用curl_httpclient:

#tornado.httpclient.AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient")

您还可以更新SimpleAsyncHTTPClient使用的CA证书文件。 它应该位于

site packages/tornado/ca证书。crt

在我的例子中,将文件
/etc/ssl/certs/ca certificates.crt
复制到tornado位置解决了这个问题


注意:如果您拥有有效的证书,但您的证书颁发机构未被tornado识别,则这将有所帮助。

您的python版本
>2.6
?如果没有,请在获取之前尝试
client.configure(“tornado.curl\httpclient.curlAsynchtpClient”)
。然后尝试
client=tornado.httpclient.asynchtpclient(disable\u ssl\u certificate\u validation=True)
。它似乎没有接收到该参数。它是httplib2中的一个参数,我没有看到tornado使用它的地方。但我认为你是对的,不知何故,我找到了答案,请看答案很好,现在接受你自己的答案;)请注意,如果忽略SSL证书有效性,那么使用HTTPS代替HTTP(没有额外的安全性)是没有意义的,因此正确的解决方案是修复证书问题。当然是YMMV。虽然证书可能无效,但通信仍将通过加密的ssl通道进行。@tigeronk2,对,但如果攻击者可以提供伪造/篡改的证书,则加密通信毫无意义。
#tornado.httpclient.AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient")