C4PS L0CK
C4PS L0CK

Reputation: 31

"Certificate verify failed: certificate has expired (_ssl.c:****)" When attempting to connect my bot to discord

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:

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.

Upvotes: 3

Views: 7629

Answers (2)

Bango
Bango

Reputation: 991

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.

Upvotes: 4

Jawad
Jawad

Reputation: 2041

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

Upvotes: 1

Related Questions