Solving Ssl: certificate_verify_failed on APIs

Dear Team,

I am facing the following issue when i try to use the Trading API
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1020)

Kindly help me in this regard. I am just following the implementations provided through README.

Regards,
Kalaimani

hi Hardick ,
Today I am also getting the same errors with different ssl code 100
Error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)…
earlier it was working fine …
pls help …

regards

Hello @kalaimani_padmanabha @nawal555

You can refer to this link: Marketfeed python program error is coming - Resolved! - #5 by Pranav_Deshmukh

i tried the above url . reinstalled certifi
error still persist

Same for me …no change …still the same error…Earlier till Friday it was working

yes …same code was working for me perfectly . now today only i got this ssl error for the same code after i regenerated my access token

hi Hardick …Any luck. Although Dhan feed is good compare to others but this kind of problems creating instability in system and constantly I am not able to use for longer period … Pls have a look on it and suggest how to fix it …as tried all possible solutions …

Hello @nawal555 @bharathi_komaravolu

Just to confirm, is this something you are facing on Live Market Feed or REST APIs?

Live Market feed Hardik…As soon as sending script codes this error is coming …

Hi @Hardik ,
Just to confirm, the solution didn’t worked.
I tried running this against the GitHub code as well.
Kindly let us know the next steps to proceed on this.

Hello @kalaimani_padmanabha @nawal555

Can you tell me which version of Python are you currently running on and the device from which you are accessing?

at my end python version is Python 3.12.4 and running Python code over HP pavilion windows 10

Also, can you check Can you check SSL version with:

openssl version

in terminal?

hi Hardick … below is my version.
OpenSSL 3.3.2 3 Sep 2024 (Library: OpenSSL 3.3.2 3 Sep 2024)

@nawal555

I am also on 3.3.* and it is working for me. Anyways, can you try with import ssl in your code at beginning?

Workaround can be by disabling it, not recommended

import ssl
import certifi

ssl._create_default_https_context = ssl._create_unverified_context

hi Hardick,
Tried but still its not working and tried with Tushar suggestion too…but with no luck…
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)

you can try installing certifi and force python to use those certificates

import ssl
import certifi

ssl._create_default_https_context = ssl.create_default_context(cafile=certifi.where())

no Tushar Its also not working …I tried yesterday as well and today also …
My historical data is working but only live feed is giving such errors …any other clue …

@Hardik

For me even LTP Fetch is also giving SSL error
I wonder why ?