Forums

SSL certificate has expired (_ssl.c:997)

i get suddently :ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:997)

My alwayw on task :

for _ in range(10): # You can change the number of attempts here
        try:
            async with websockets.connect("wss://stream.aisstream.io/v0/stream", ping_interval=None) as websocket: # Disable the ping interval here
                subscribe_message = {"APIKey": "b24e64336cd080d430fb703bd47a2e90d60aa6de", "BoundingBoxes": [[[-90, -180], [90, 180]]]}

                subscribe_message_json = json.dumps(subscribe_message)
                await websocket.send(subscribe_message_json)



                async for message_json in websocket:
                    message = json.loads(message_json)
                    message_type = message["MessageType"]

Could you show the full error message you see at the bottom of the log?

Use this

import certifi
import ssl
context = ssl.create_default_context()
context.load_verify_locations(certifi.where())
ssl._create_default_https_context = ssl._create_unverified_context

It should work but it is unsafe.