alpacahq / alpaca-trade-api-python

Python client for Alpaca's trade API
https://pypi.org/project/alpaca-trade-api/
Apache License 2.0
1.72k stars 530 forks source link

[Bug]: ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992) #723

Open icocoding opened 10 months ago

icocoding commented 10 months ago

Is there an existing issue for this?

Current Behavior

When I used stream to get data on Mac air M1, got that error. Then I fixed it by myself.

stream = Stream(ALPACA_API_KEY,
                ALPACA_SECRET_KEY,
                data_feed='iex',
                )

error: ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992)

Expected Behavior

No response

SDK Version I encountered this issue in

3.0.2

Steps To Reproduce

stream = Stream(ALPACA_API_KEY,
                ALPACA_SECRET_KEY,
                data_feed='iex',
                )

Filled out the Steps to Reproduce section?

Anything else?

FIXED:

import ssl
sslcontext = ssl._create_unverified_context()

stream = Stream(ALPACA_API_KEY,
                ALPACA_SECRET_KEY,
                data_feed='iex',
                websocket_params=dict(ssl=sslcontext)
                )