SSL errors during token

I am using electron framework for building desktop app. I am able to call the authorize API and get the code. I am using axios library to make the http calls. Next when I call /login/authorization/token , I get an error with SSL.
cause: Error: unable to verify the first certificate
at TLSSocket.onConnectSecure (node:_tls_wrap:1603:34)
at TLSSocket.emit (node:events:517:28)
at TLSSocket._finishInit (node:_tls_wrap:1020:8)
at ssl.onhandshakedone (node:_tls_wrap:806:12) {
code: ‘UNABLE_TO_VERIFY_LEAF_SIGNATURE’
}
The same is working with Postman. What certificate I need for this and is there anyway to circumvent this error ?

This issue seems to be specific to your local development environment. However, you might find useful insights in this article that addresses a similar problem and its solution: Unable to verify the first certificate in Node.js & Postman | bobbyhadz.

Should you encounter any issues related to the Upstox API, please don’t hesitate to contact us for assistance.

@Pradeep_Jaiswar - I am following upstox documentation to connect through python script. So far I am able to generate code for requesting token. however I am ended with below error. can you please suggest any solution?

SSLError: HTTPSConnectionPool(host=‘api.upstox.com’, port=443): Max retries exceeded with url: /v2/login/authorization/token (Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)’)))

This error occurs when requests library tries to establish a secure HTTPS connection to api.upstox.com, but fails to verify the SSL certificate. The system is unable to obtain the local issuer certificate, which means your machine is missing or unable to verify the root certificate authority (CA).

You need to have the necessary CA certificates to verify the SSL connection.

Thanks Pradeep, Is there anyway to identify root cause or error that highlight its problem with my machine or OS as my desktop support wont agree with your explanation.
Also suggest, Is there alternate way to install required upstox root certificate ?

I managed to resolve issue by installing system cert using 'pip install pip-system-certs"

2 Likes