Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to fix "Exception has occurred: SSLError HTTPSConnectionPool" in VS Code environment

i try to use python requests library but i got this error
i use psiphon VPN most of time in Windows 10
and got this below error after calling requests.get('[API URL]')

Exception has occurred: SSLError
HTTPSConnectionPool(host='api.github.com', port=443): Max retries exceeded with url: /user (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:997)')))

During handling of the above exception, another exception occurred:


During handling of the above exception, another exception occurred:

  File "C:\Users\Hessam\Desktop\QWE.py", line 3, in <module>
    r = requests.get('https://api.github.com/user', auth=('user', 'pass'))

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You should try to add verify=False to your request:

import requests
r = requests.get('https://api.github.com/user', verify=False)

requests verifies SSL certificates for HTTPS requests, just like a web browser. By default, SSL verification is enabled, and requests will throw an SSLError if it’s unable to verify the certificate.

In your specific case, you most likely have a problem with the SSL certificate on your VPN.

Note that when verify is set to False, requests will accept any TLS certificate presented by the server, and will ignore hostname mismatches and/or expired certificates, which will make your application vulnerable to man-in-the-middle (MitM) attacks. Setting verify to False may be useful during local development or testing.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading