-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Windows build failing with SSL error #733
- Loading branch information
1 parent
295b8b0
commit ea577ba
Showing
3 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Monkey patch https://github.com/pystatgen/sgkit/issues/733 | ||
import ssl | ||
|
||
|
||
def _ssl_load_windows_store_certs(self, storename, purpose): # type: ignore[no-untyped-def] # pragma: no cover | ||
# Code adapted from _load_windows_store_certs in https://github.com/python/cpython/blob/main/Lib/ssl.py | ||
try: | ||
certs = [ | ||
cert | ||
for cert, encoding, trust in ssl.enum_certificates(storename) # type: ignore | ||
if encoding == "x509_asn" and (trust is True or purpose.oid in trust) | ||
] | ||
except PermissionError: | ||
return | ||
for cert in certs: | ||
try: | ||
self.load_verify_locations(cadata=cert) | ||
except ssl.SSLError: | ||
pass | ||
|
||
|
||
ssl.SSLContext._load_windows_store_certs = _ssl_load_windows_store_certs # type: ignore |