Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the SSL_CERT_FILE environment variables via an activation script on Windows #21

Merged
merged 5 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions recipe/activate.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
if "%SSL_CERT_FILE%"=="" (
set SSL_CERT_FILE="%LIBRARY_PREFIX%\ssl\cacert.pem"
set __CONDA_OPENSLL_CERT_FILE_SET="1"
)
4 changes: 4 additions & 0 deletions recipe/activate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
if [[ "$SSL_CERT_FILE" == "" ]]; then
export SSL_CERT_FILE="${LIBRARY_PREFIX}\\ssl\\cacert.pem"
export __CONDA_OPENSLL_CERT_FILE_SET="1"
fi
13 changes: 13 additions & 0 deletions recipe/bld.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
setlocal EnableDelayedExpansion

if "%ARCH%"=="32" (
set OSSL_CONFIGURE=VC-WIN32
) ELSE (
Expand All @@ -14,6 +16,8 @@ REM write permissions to limit the risk of non-privileged users exploiting
REM OpenSSL's engines feature to perform arbitrary code execution attacks
REM against applications that load the OpenSSL DLLs.
REM
REM On top of that, we also set the SSL_CERT_FILE environment variable
REM via an activation script to point to the ca-certificates provided CA root file.
set PERL=%BUILD_PREFIX%\Library\bin\perl
%BUILD_PREFIX%\Library\bin\perl configure %OSSL_CONFIGURE% ^
--prefix=%LIBRARY_PREFIX% ^
Expand Down Expand Up @@ -63,3 +67,12 @@ rem copy out32dll\ssleay32.dll %LIBRARY_BIN%\ssleay32.dll
rem copy out32dll\libeay32.dll %LIBRARY_BIN%\libeay32.dll
rem mkdir %LIBRARY_INC%\openssl
rem xcopy /S inc32\openssl\*.* %LIBRARY_INC%\openssl\

:: Copy the [de]activate scripts to %PREFIX%\etc\conda\[de]activate.d.
:: This will allow them to be run on environment activation.
for %%F in (activate deactivate) DO (
if not exist %PREFIX%\etc\conda\%%F.d mkdir %PREFIX%\etc\conda\%%F.d
copy %RECIPE_DIR%\%%F.bat %PREFIX%\etc\conda\%%F.d\%PKG_NAME%_%%F.bat
:: Copy unix shell activation scripts, needed by Windows Bash users
copy %RECIPE_DIR%\%%F.sh %PREFIX%\etc\conda\%%F.d\%PKG_NAME%_%%F.sh
)
4 changes: 4 additions & 0 deletions recipe/deactivate.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
if "%__CONDA_OPENSLL_CERT_FILE_SET%" == "1" (
set SSL_CERT_FILE=
set __CONDA_OPENSLL_CERT_FILE_SET=
)
4 changes: 4 additions & 0 deletions recipe/deactivate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
if [[ "$__CONDA_OPENSLL_CERT_FILE_SET" == "1" ]]; then
unset SSL_CERT_FILE
unset
JeanChristopheMorinPerso marked this conversation as resolved.
Show resolved Hide resolved
fi
7 changes: 2 additions & 5 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ source:
url: https://www.openssl.org/source/{{ name }}-{{ version }}.tar.gz
sha256: 1761d4f5b13a1028b9b6f3d4b8e17feb0cedc9370f6afe61d7193d2cdce83323
build:
number: 0
number: 1
no_link: lib/libcrypto.so.3.0 # [linux]
no_link: lib/libcrypto.3.0.dylib # [osx]
has_prefix_files: # [unix]
Expand Down Expand Up @@ -39,16 +39,13 @@ requirements:

test:
requires:
- certifi # [win]
- python 3.8
- six
commands:
- copy NUL checksum.txt # [win]
- touch checksum.txt # [unix]
- openssl sha256 checksum.txt
- openssl ecparam -name prime256v1
- python -c "from six.moves import urllib; urllib.request.urlopen('https://pypi.org')" # [unix]
- python -c "import certifi; import ssl; import urllib.request as urlrq; urlrq.urlopen('https://pypi.org', context=ssl.create_default_context(cafile=certifi.where()))" # [win]
- python -c "import urllib.request; urllib.request.urlopen('https://pypi.org')"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be extra beneficial to also check in the test.commands section that cacert.pem are also delivered and present in the intended ${CONDA_PREFIX} path?

JeanChristopheMorinPerso marked this conversation as resolved.
Show resolved Hide resolved

about:
home: https://www.openssl.org/
Expand Down