I'm having issues in android (kivy) about ssl verification:
02-12 18:19:15.622 5082 5116 I python : geopy.exc.GeocoderUnavailable: HTTPSConnectionPool(host='nominatim.openstreetmap.org', port=443): Max retries exceeded with url: /search?q=Buenos+Aires+Argentina&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)')))
So I would like to change ssl context to ignore verification completely until I found right settings to make it work, I read this page on official documentation, in order to be able to turn off ssl verification: https://geopy.readthedocs.io/en/stable/#geopy.geocoders.options.default_ssl_context but it doesn't change anything.
So I used the example on mine method like this:
def _locating_place(self, place, country) -> Point:
# self.ssl_ctx is a boolean variable set to True if the app runs in android
if self.ssl_ctx:
Logger.info('setting custom ssl context')
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
geopy.geocoders.options.default_ssl_context = ctx
geolocator = Nominatim(user_agent='myapplication')
else:
geolocator = Nominatim(user_agent='myapplication')
location = geolocator.geocode(f"{place} {country}")
I also tried passing context ctx
like this: geolocator = Nominatim(user_agent='myapplication', ssl_context=ctx)
, the result is the same, mine code once reaches geocode()
method call, in android, fails verifying ssl certificate, like this:
02-12 18:19:15.621 5082 5116 I python : File "/srv/buildozer_build_dir/android/app/lib/weather/weather_getter.py", line 312, in _locating_place
02-12 18:19:15.621 5082 5116 I python : File "/srv/buildozer_build_dir/android/platform/build-armeabi-v7a_x86_64_x86_arm64-v8a/build/python-installs/travel_lint/x86/geopy/geocoders/nominatim.py", line 297, in geocode
02-12 18:19:15.621 5082 5116 I python : File "/srv/buildozer_build_dir/android/platform/build-armeabi-v7a_x86_64_x86_arm64-v8a/build/python-installs/travel_lint/x86/geopy/geocoders/base.py", line 368, in _call_geocoder
02-12 18:19:15.621 5082 5116 I python : File "/srv/buildozer_build_dir/android/platform/build-armeabi-v7a_x86_64_x86_arm64-v8a/build/python-installs/travel_lint/x86/geopy/adapters.py", line 447, in get_json
02-12 18:19:15.622 5082 5116 I python : File "/srv/buildozer_build_dir/android/platform/build-armeabi-v7a_x86_64_x86_arm64-v8a/build/python-installs/travel_lint/x86/geopy/adapters.py", line 469, in _request
02-12 18:19:15.622 5082 5116 I python : geopy.exc.GeocoderUnavailable: HTTPSConnectionPool(host='nominatim.openstreetmap.org', port=443): Max retries exceeded with url: /search?q=Buenos+Aires+Argentina&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)')))
02-12 18:19:15.622 5082 5116 I python : Python for android ended.
Am I doing something wrong? Do I need to change Nominatim instantiation or pass some arguments to geocode method?