pythonpython-3.xsendgrid

SSL Certificate Verification Failed with Sendgrid send


I am getting an SSL verification failed error when trying to send emails with the Sendgrid web api. I'm not even sure what cert it is trying to verify here. I have done all of the user and domain verification on my Sendgrid account and I am using very straightforward sending process.

Here the error

urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1000)>

Heres the code

mailClient = SendGridAPIClient(os.environ.get('sendGridKey'))
message = Mail(
            from_email=os.environ['sendGridEmail'],
            to_emails="dev@cribbi.co",
            subject="User Message for %s" %newMessage['chatId'],
            html_content = "<strong>" + newMessage['message']['text'] + "</strong>"
        )

mailRes = mailClient.send(message)

Solution

  • Here is a link to the answer. It is not sendgrid specific but Python version specific. I was able to use the link provided in this answer to find the script that I needed to run to update the SSL certs for python.

    urllib and "SSL: CERTIFICATE_VERIFY_FAILED" Error