Skip to content

armgit / Aleph

Public Imported from GitHub
0

Give satellite imagery, terrain data, buildings, streetview photos to your LLM

Fix CERTIFICATE_VERIFY_FAILED on macOS

Belluxxef185f2271ed
diff --git a/README.md b/README.md
index de7fe5b..a3da3d1 100644
--- a/README.md
+++ b/README.md
@@ -32,7 +32,7 @@ This was born as a way to let LLMs quickly gather information from the physical
## Install
-Requires Python 3.11+. The only dependencies are Pillow and numpy. No API keys are required.
+Requires Python 3.11+. The only dependencies are Pillow, numpy, and truststore. No API keys are required.
```sh
git clone https://github.com/Belluxx/Aleph.git
diff --git a/pyproject.toml b/pyproject.toml
index 8d34f6b..f419c8f 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -8,7 +8,7 @@ version = "0.2.0"
description = "Capture Street View photos, satellite imagery, and OpenStreetMap data."
readme = "README.md"
requires-python = ">=3.11"
-dependencies = ["Pillow>=10", "numpy>=1.25"]
+dependencies = ["Pillow>=10", "numpy>=1.25", "truststore>=0.10"]
[project.scripts]
alephgeo = "aleph:main"
diff --git a/src/common.py b/src/common.py
index 2824a55..59a30fd 100644
--- a/src/common.py
+++ b/src/common.py
@@ -5,6 +5,7 @@ import json
import math
import os
import shutil
+import ssl
import sys
import tempfile
import threading
@@ -20,6 +21,7 @@ from urllib.error import HTTPError
from urllib.parse import urlencode, urlsplit
from urllib.request import Request, urlopen
+import truststore
from PIL import Image
DEFAULT_CACHE = Path(os.environ.get("XDG_CACHE_HOME", str(Path.home() / ".cache"))) / "aleph"
@@ -131,7 +133,10 @@ class Client:
if self.request_log:
self.request_log("GET", address, attempt)
try:
- with urlopen(Request(address, headers={"User-Agent": user_agent}), timeout=timeout) as response:
+ # Trust the OS certificate store: python.org builds for macOS ship with none of their own.
+ # One context per request: truststore locks a context for the whole handshake.
+ with urlopen(Request(address, headers={"User-Agent": user_agent}), timeout=timeout,
+ context=truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT)) as response:
if destination is None:
result = response.read()
else: