Search code examples
pythonssl-certificatetornado

Tornado : [SSL: CERTIFICATE_VERIFY_FAILED]


I'm trying to run this program so that I can understand asynchronous programming using tornado.

import tornado.ioloop
from tornado.httpclient import AsyncHTTPClient
url = 'https://jsonplaceholder.typicode.com/posts'

def handle_response(response):
      url = response.request.url
      data = response.body
      print('{}: {} bytes: {}'.format(url, len(data), data))

http_client = AsyncHTTPClient()

http_client.fetch(url, handle_response)
 
tornado.ioloop.IOLoop.instance().start()

However, I am getting this error when I am trying to run it

[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1045)


Solution

  • The SSL error was because Python 3.7 does not rely on MacOS' openSSL anymore. It comes with its own openSSL bundled and doesn't have access on MacOS' root certificates. So all I needed to do was run the following command-

    /Applications/Python\ 3.7/Install\ Certificates.command