Fix SSL cert verification in PyInstaller binaries via certifi

PyInstaller-bundled Python cannot find system CA certs on Linux/macOS.
Use certifi's bundled CA bundle for all GitHub API requests.

https://claude.ai/code/session_01MqEqGhP1guGx5VuFsLaws2
This commit is contained in:
Claude 2026-05-08 17:05:38 +00:00
parent cbfb2d5360
commit 69677b31ca
No known key found for this signature in database
3 changed files with 7 additions and 2 deletions

View file

@ -42,7 +42,7 @@ jobs:
python-version: "3.12" python-version: "3.12"
- name: Install dependencies - name: Install dependencies
run: pip install pyinstaller click pyyaml run: pip install pyinstaller click pyyaml certifi
- name: Build binary - name: Build binary
run: pyinstaller --onefile --name mdcms mdcms.py run: pyinstaller --onefile --name mdcms mdcms.py

View file

@ -10,10 +10,13 @@
import json import json
import os import os
import re import re
import ssl
import urllib.error import urllib.error
import urllib.request import urllib.request
from pathlib import Path from pathlib import Path
import certifi
import click import click
import yaml import yaml
@ -434,7 +437,8 @@ def _github_get(url: str) -> bytes:
"Accept": "application/vnd.github.v3+json", "Accept": "application/vnd.github.v3+json",
}, },
) )
with urllib.request.urlopen(req, timeout=15) as resp: ctx = ssl.create_default_context(cafile=certifi.where())
with urllib.request.urlopen(req, timeout=15, context=ctx) as resp:
return resp.read() return resp.read()

View file

@ -13,6 +13,7 @@ requires-python = ">=3.9"
dependencies = [ dependencies = [
"click>=8.0", "click>=8.0",
"PyYAML>=6.0", "PyYAML>=6.0",
"certifi>=2024.0",
] ]
[project.scripts] [project.scripts]