Skip to content

Add --ignore-ssl-errors flag and SSL certificate documentation#166

Open
philipdenys wants to merge 2 commits intooriginalankur:mainfrom
philipdenys:fix/add-ssl-ignore-option
Open

Add --ignore-ssl-errors flag and SSL certificate documentation#166
philipdenys wants to merge 2 commits intooriginalankur:mainfrom
philipdenys:fix/add-ssl-ignore-option

Conversation

@philipdenys
Copy link

Summary

This PR adds support for bypassing SSL certificate verification errors commonly encountered on macOS when Python certificates are not properly installed.

Problem

Users on macOS with Python installed from python.org frequently encounter SSL certificate verification errors when the script tries to geocode cities using the Nominatim API:

SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1002)'))

Changes Made

1. New Command-Line Flag

  • Added --ignore-ssl-errors flag to bypass SSL certificate verification
  • Includes warning message when flag is active
  • Not recommended for production use - only for development/testing

2. SSL Patching Implementation

  • Monkey-patches ssl._create_default_https_context when flag is enabled
  • Lazy-loads geopy.geocoders.Nominatim to ensure patch takes effect before import
  • Disables urllib3 SSL warnings to reduce noise
  • Updated get_coordinates() function signature to accept the flag (though patching happens globally)

3. Documentation

  • Created SSL_CERTIFICATE_ISSUE.md with:
    • Problem description and root cause explanation
    • Recommended solution: Run /Applications/Python X.XX/Install Certificates.command
    • Alternative solution: Use --ignore-ssl-errors flag (with security warnings)
    • Implementation details

Usage Example

Development/Testing (with flag):

python3 create_map_poster.py --ignore-ssl-errors -c Antwerp -C Belgium -t japanese_ink -d 15000

Recommended Approach (install certificates):

/Applications/Python\ 3.11/Install\ Certificates.command
python3 create_map_poster.py -c Antwerp -C Belgium -t japanese_ink -d 15000

Testing

  • Tested on macOS with Python 3.11 experiencing SSL certificate errors
  • Confirmed warning message appears when flag is used
  • Verified lazy loading of geopy module

Security Note

The --ignore-ssl-errors flag is provided as a convenience for development and testing only. Users should be strongly encouraged to install proper SSL certificates using the recommended method.

Related Issues

Addresses SSL certificate verification failures on macOS when using Python installed from python.org (not system Python or Homebrew).

Fixes: Certificate verification errors with nominatim.openstreetmap.org geocoding requests

## Summary
Added support for bypassing SSL certificate verification errors commonly
encountered on macOS when Python certificates are not properly installed.

## Changes Made

### 1. New Command-Line Flag
- Added `--ignore-ssl-errors` flag to bypass SSL certificate verification
- Includes warning message when flag is active
- Not recommended for production use

### 2. SSL Patching Implementation
- Monkey-patches `ssl._create_default_https_context` when flag is enabled
- Lazy-loads geopy.geocoders.Nominatim to ensure patch takes effect
- Disables urllib3 SSL warnings to reduce noise

### 3. Documentation
- Created SSL_CERTIFICATE_ISSUE.md with:
  - Problem description and root cause
  - Recommended solution (Install Certificates.command)
  - Alternative solution (--ignore-ssl-errors flag)
  - Implementation details and security warnings

## Testing
Tested on macOS with Python 3.11 experiencing SSL certificate errors.

## Usage Example
```bash
# Development/testing only:
python3 create_map_poster.py --ignore-ssl-errors -c Antwerp -C Belgium -t japanese_ink -d 15000

# Recommended approach:
/Applications/Python\ 3.11/Install\ Certificates.command
python3 create_map_poster.py -c Antwerp -C Belgium -t japanese_ink -d 15000
```

## Related Issues
Addresses SSL certificate verification failures on macOS when using
Python installed from python.org (not system Python or Homebrew).

Fixes: Certificate verification errors with nominatim.openstreetmap.org
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants