sunnyxx
sunnyxx

Reputation: 557

Using "tornado.httpclient" fetch "POST https" site get "HTTPError: HTTP 599"

I want to use "tornado.httpclient.AsyncHTTPClient" to send a "POST" request to a "https" website, but get:

HTTPError: HTTP 599: [Errno 1] _ssl.c:503: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed  

It works when I use "urllib" instead(with same url and parameters,headers I don't know)
code like this:

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()

Upvotes: 4

Views: 8275

Answers (2)

sunnyxx
sunnyxx

Reputation: 557

request = tornado.httpclient.HTTPRequest(url=url, method='POST', body=body,
                                         validate_cert=False)

add "validate_cert=False" when gen a http request
and seems no need to use curl_httpclient:

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

Upvotes: 4

Alex Markov
Alex Markov

Reputation: 321

You can also update CA certificates file used by SimpleAsyncHTTPClient. It should be located in

site-packages/tornado/ca-certificates.crt

In my case copying file /etc/ssl/certs/ca-certificates.crt to tornado location solved the problem.

Note: it will help in case if you have valid certificate but your Certificate Authority is not recognised by tornado.

Upvotes: 1

Related Questions