Skip to content

Commit 525e162

Browse files
committed
CI: Install Root CA certificates to satisfy Python 3.11 on macOS
References: - https://stackoverflow.com/a/44649450 - Unbabel/COMET#29 (comment) - https://github.com/python/cpython/blob/main/Mac/BuildScript/resources/install_certificates.command Root cause:: Error: Error downloading extends for URL https://cdn.crate.io/downloads/releases/cratedb/x64_mac/crate-5.0.1.tar.gz: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992)>
1 parent d4f35bf commit 525e162

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

.github/workflows/nightly.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ jobs:
3737
- name: Invoke tests
3838
run: |
3939
40+
# Install Root CA certificates
41+
sudo ./devtools/install_certifi.py
42+
4043
# Bootstrap environment.
4144
source bootstrap.sh
4245

.github/workflows/tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ jobs:
3838
- name: Invoke tests
3939
run: |
4040
41+
# Install Root CA certificates
42+
sudo ./devtools/install_certifi.py
43+
4144
# Bootstrap environment.
4245
source bootstrap.sh
4346

devtools/install_certifi.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env python
2+
3+
# install_certifi.py
4+
#
5+
# sample script to install or update a set of default Root Certificates
6+
# for the ssl module. Uses the certificates provided by the certifi package:
7+
# https://pypi.python.org/pypi/certifi
8+
#
9+
# References:
10+
#
11+
# - https://stackoverflow.com/a/44649450
12+
# - https://github.com/Unbabel/COMET/issues/29#issuecomment-945601519
13+
# - https://github.com/python/cpython/blob/main/Mac/BuildScript/resources/install_certificates.command
14+
15+
import os
16+
import os.path
17+
import ssl
18+
import stat
19+
import subprocess
20+
import sys
21+
22+
STAT_0o775 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
23+
| stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP
24+
| stat.S_IROTH | stat.S_IXOTH )
25+
26+
27+
def main():
28+
openssl_dir, openssl_cafile = os.path.split(
29+
ssl.get_default_verify_paths().openssl_cafile)
30+
31+
print(" -- pip install --upgrade certifi")
32+
subprocess.check_call([sys.executable,
33+
"-E", "-s", "-m", "pip", "install", "--upgrade", "certifi"])
34+
35+
import certifi
36+
37+
# change working directory to the default SSL directory
38+
os.chdir(openssl_dir)
39+
relpath_to_certifi_cafile = os.path.relpath(certifi.where())
40+
print(" -- removing any existing file or link")
41+
try:
42+
os.remove(openssl_cafile)
43+
except FileNotFoundError:
44+
pass
45+
print(" -- creating symlink to certifi certificate bundle")
46+
os.symlink(relpath_to_certifi_cafile, openssl_cafile)
47+
print(" -- setting permissions")
48+
os.chmod(openssl_cafile, STAT_0o775)
49+
print(" -- update complete")
50+
51+
52+
if __name__ == '__main__':
53+
main()

0 commit comments

Comments
 (0)