3

I'm making a discord bot using python. When I try to run it to connect my client to discord I get this error:

raise ClientConnectorCertificateError( aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discord.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:****)')]

Happens every time I try to run it.

I saw a plausible fix for this which was:

  • Go to discord.com with Internet Explorer (Ran as Administrator)
  • Click the lock on the top right
  • Click view certificates
  • Install one

However, when I tried it and then tried to run my bot again I still got the same error.

Dont know if this is relevant but at the start of the error message in the Traceback section it says the first call that started the error is in the last line of my bot's code which is client.run(TOKEN).

I'm using Python 3.8 on Windows 10.

Liju Thomas
  • 1,054
  • 5
  • 18
  • 25
C4PS L0CK
  • 31
  • 1
  • 3

2 Answers2

4

TL;DR Your certificate has expired, and you need to download and install the new one to your local machine by downloading it from the website and installing it into your OS.

This solution is performed using Google Chrome and Windows 10.

  1. Go to the website you're trying to request
  2. Click the lock icon to the left of the URL entry field
  3. If it says Certificate (Valid), you're in business. Click that
  4. In the resulting window, click the Details tab
  5. Click Copy to File...
  6. In the certificate export wizard, select Cryptographic Message Syntax Standard (.P7B)
  7. Check the box under it, Include all certificates in the cert path if possible
  8. Click next, click Browse and choose a folder, create a name for the file and click Save
  9. Next, Finish
  10. Open the file you just exported. If you're on windows, it will open certificate manager
  11. Navigate deeper into the folders to find the actual certs
  12. One by one, double click each cert and choose Install Certificate, for the current user, and automatically select where it goes

Once you install all the certificates required to validate the HTTPS request, your script shouldn't encounter the certificate expired error anymore, until the new certs expire.

You can also check when each cert expires in certmgr.

Bango
  • 971
  • 6
  • 18
1

Download and install this certificate.

It can be installed by double clicking the file and installing it to Local Computer, download link location: certificate download

Jawad
  • 1,971
  • 1
  • 7
  • 17
  • All good I found my problem. Turns out I don't even have ssl on my computer so I moved everything to my linux server which has ssl and everything worked just fine. Thank you though! – C4PS L0CK Sep 04 '20 at 21:15