How can we resolve 'certificate verify failed' error? - python

I am trying to run this simple script on my company laptop.
from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="ryan_data")
location = geolocator.geocode("175 5th Avenue NYC")
print(location.address)
When I run that code I get this error message.
GeocoderUnavailable: HTTPSConnectionPool(host='nominatim.openstreetmap.org', port=443): Max retries exceeded with url: /search?q=175+5th+Avenue+NYC&format=json&limit=1 (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))
If I run the exact code on my personal laptop, everything works totally fine. I think there is some kind of VPN issue or maybe firewall issue, on the corporate laptop. I Googled the error and found a couple things on this topic, but not much really. I feel like there should be an easy work-around, but after Googling this and trying a couple ideas, I am still stuck! Has anyone here encountered this issue and resolved it? If so, please do share your thoughts!

Related

My geopy.geocoders is throwing error: SSL: CERTIFICATE_VERIFY_FAILED. How can I resolve this? [duplicate]

This question already has answers here:
certificate verify failed: unable to get local issuer certificate
(21 answers)
Scraping: SSL: CERTIFICATE_VERIFY_FAILED error for http://en.wikipedia.org
(22 answers)
Unable to get local issuer certificate when using requests in python
(8 answers)
certificate verify failed: unable to get local issuer certificate python requests
(2 answers)
Closed last month.
When I try to run this code.
from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="ryan_data")
location = geolocator.geocode("175 5th Avenue NYC")
print(location.address)
I get this error.
GeocoderUnavailable: HTTPSConnectionPool(host='nominatim.openstreetmap.org', port=443): Max retries exceeded with url: /search?q=175+5th+Avenue+NYC&format=json&limit=1 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)')))
This should be a pretty simple thing, but I can't get the code to run. I'm trying to run the code on my corporate laptop. The exact same code works perfectly find on my personal laptop. Any idea what's wrong here?
Documentation is here.
https://geopy.readthedocs.io/en/stable/#module-geopy.geocoders

SSL Certificate Error when using an API - troubleshooting methods

I cannot access the Darksky API (weather forecast API) from a python script on my home internet while it runs fine on the office internet. Also, when I paste the Darksky url on a web browser it works fine, too. I read somewhere that both office internet and web browser have their own intermediate certificates while my home internet may not.
This is the error message:
'HTTPSConnectionPool(host='api.darksky.net', port=443): Max retries exceeded with url: /forecast/key/lat,long?units=us&exclude=hourly,minutely,daily (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))']
I'm on a Linux machine. I've tried downloading PEM(cert) and PEM(chain) certificate files from the web browser and saving them to "/usr/local/share/ca-certificates" and "/etc/ssl/certs" folders. I then ran the "sudo update-ca-certificates" command. I've also tried changing the file extension to ".crt", but no luck.
What other troubleshooting methods are there? Thank you!

Python Binance request blocked by internet provider

Currently, i am working to automate my binance account using python-binance 1.0.0++
Unfortunately, the web is blocked by the government but I still can access the web using public DNS (google / cloudflare) by setup the security settings. Or i can also add the DNS to my Network Adapter
But when I try the python-binance to get_all_orders, then the result still shows a scraped blocked landing page by our government even when i do browsing using the chrome / edge, no issue at all. I have tried to change the DNS at the browser and at Network Adapter. Nothing are work for me. The error is shown below.
requests.exceptions.SSLError: HTTPSConnectionPool(host='api.binance.com', port=443): Max retries exceeded with url: /api/v3/ping (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)')))
Anyone can help me to do the same on my python as my browser work?

When adding package to PyPi SSL error occurs

I am trying to add a package to PyPi so I can install it with Pip. I am trying to add it using twine upload dist/*.
This causes me to get multiple SSL errors such as raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='upload.pypi.org', port=443): Max retries exceeded with url: /legacy/ (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])"))).
I am using a school laptop and I presume that this is something my administrator has done however I can install stuff with pip by using pip3 install --trusted-host pypi.org --trusted-h\ost files.pythonhosted.org.
I was wondering if there was another to add my package to pip?
My guess is your school has something in place where they are replacing the original cert with their own, you could maybe get around it using --cert and referencing the path for your schools cert, but I think an easier workaround is to copy the files to a non school computer and upload from there.
This could be a number of things, including an out-of-date version of twine, or (more likely) an out-of-date version of OpenSSL. Some possible solutions are listed here: https://github.com/pypa/twine/issues/273

SSL error - Python3

up until yesterday i've been using Spyder on Anaconda to run code with no issues whatsoever. Today, while running one of my scripts that include quandl, i get an SSL error
"SSLError: HTTPSConnectionPool(host='www.quandl.com', port=443): Max
retries exceeded with url: /api/v3/datasets/WIKI/EIX/data?order=asc
(Caused by SSLError(SSLError("bad handshake: Error([('SSL routines',
'ssl3_get_server_certificate', 'certificate verify failed')],)",),))"
I then uninstalled my Anaconda and installed the most recent version, and am now getting an HTTP error
"CondaHTTPError: HTTP 000 CONNECTION FAILED for url
https://repo.anaconda.com/pkgs/r/win-64/repodata.json.bz2"
It seems that every request is being denied (including any other package i attempt to upgrade or install using pip or conda including pip and conda themselves), does someone have any clue as to what is happening? I could really use some help, i'm completely stumped and really need to get back to work.
Thank you in advance.

Categories

Resources