fix: setup OpenSSL certificates in `macos-pkg-setup-template.sh` (#189)

The macOS pkg installer does not setup default certificates for OpenSSL.
A script is provided by the macOS pkg installer to setup those using the certifi PyPI package.
Let's run this script as part of the setup template in order to be able to do HTTPS downloads out of the box.
This commit is contained in:
Matthieu Darbois 2022-10-03 10:13:05 +02:00 committed by GitHub
parent a1a012d197
commit 1e1d9f9032
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 0 deletions

View File

@ -20,6 +20,7 @@ PYTHON_TOOLCACHE_PATH=$TOOLCACHE_ROOT/Python
PYTHON_TOOLCACHE_VERSION_PATH=$PYTHON_TOOLCACHE_PATH/$PYTHON_FULL_VERSION
PYTHON_TOOLCACHE_VERSION_ARCH_PATH=$PYTHON_TOOLCACHE_VERSION_PATH/x64
PYTHON_FRAMEWORK_PATH="/Library/Frameworks/Python.framework/Versions/${MAJOR_VERSION}.${MINOR_VERSION}"
PYTHON_APPLICATION_PATH="/Applications/Python ${MAJOR_VERSION}.${MINOR_VERSION}"
echo "Check if Python hostedtoolcache folder exist..."
if [ ! -d $PYTHON_TOOLCACHE_PATH ]; then
@ -64,5 +65,8 @@ echo "Upgrading pip..."
./python -m ensurepip
./python -m pip install --ignore-installed pip --disable-pip-version-check --no-warn-script-location
echo "Install OpenSSL certificates"
sh -e "${PYTHON_APPLICATION_PATH}/Install Certificates.command"
echo "Create complete file"
touch $PYTHON_TOOLCACHE_VERSION_PATH/x64.complete

View File

@ -96,4 +96,8 @@ Describe "Tests" {
"./dist/simple-test" | Should -ReturnZeroExitCode
}
}
It "Check urlopen with HTTPS works" {
"python ./sources/python-urlopen-https.py" | Should -ReturnZeroExitCode
}
}

View File

@ -0,0 +1,10 @@
import sys
if sys.version_info[0] == 2:
from urllib2 import urlopen
else:
from urllib.request import urlopen
response = urlopen("https://raw.githubusercontent.com/actions/python-versions/c641695f6a07526c18f10e374e503e649fef9427/.gitignore")
data = response.read()
assert len(data) == 140, len(data)