diff --git a/mingw-openssl.spec b/mingw-openssl.spec index b38cd86..88b7c5b 100644 --- a/mingw-openssl.spec +++ b/mingw-openssl.spec @@ -15,7 +15,7 @@ Name: mingw-openssl Version: 3.0.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: MinGW port of the OpenSSL toolkit License: OpenSSL @@ -57,6 +57,10 @@ Patch11: 0011-Remove-EC-curves.patch # Instructions to load legacy provider in openssl.cnf Patch24: 0024-load-legacy-prov.patch +# MinGW patches +# Attempt to compute openssl modules dir dynamically from executable path if not set by OPENSSL_MODULES +Patch100: openssl_compute_moddir.patch + BuildArch: noarch BuildRequires: make @@ -368,6 +372,9 @@ mkdir -m700 %{buildroot}%{mingw64_sysconfdir}/pki/CA/private %changelog +* Mon Feb 21 2022 Sandro Mani - 3.0.0-2 +- Attempt to compute openssl modules dir dynamically from executable path if not set by OPENSSL_MODULES + * Sun Jan 30 2022 Sandro Mani - 3.0.0-1 - Update to 3.0.0 diff --git a/openssl_compute_moddir.patch b/openssl_compute_moddir.patch new file mode 100644 index 0000000..6bef68e --- /dev/null +++ b/openssl_compute_moddir.patch @@ -0,0 +1,54 @@ +diff -rupN openssl-3.0.0/Configurations/10-main.conf openssl-3.0.0-new/Configurations/10-main.conf +--- openssl-3.0.0/Configurations/10-main.conf 2021-09-07 13:46:32.000000000 +0200 ++++ openssl-3.0.0-new/Configurations/10-main.conf 2022-02-21 20:18:52.135333228 +0100 +@@ -1469,7 +1469,7 @@ my %targets = ( + cppflags => combine("-DUNICODE -D_UNICODE -DWIN32_LEAN_AND_MEAN", + threads("-D_MT")), + lib_cppflags => "-DL_ENDIAN", +- ex_libs => add("-lws2_32 -lgdi32 -lcrypt32"), ++ ex_libs => add("-lws2_32 -lgdi32 -lcrypt32 -lpathcch"), + thread_scheme => "winthreads", + dso_scheme => "win32", + shared_target => "mingw-shared", +diff -rupN openssl-3.0.0/crypto/provider_core.c openssl-3.0.0-new/crypto/provider_core.c +--- openssl-3.0.0/crypto/provider_core.c 2021-09-07 13:46:32.000000000 +0200 ++++ openssl-3.0.0-new/crypto/provider_core.c 2022-02-21 20:02:05.674653366 +0100 +@@ -27,6 +27,10 @@ + #ifndef FIPS_MODULE + # include + #endif ++#ifdef _WIN32 ++# include ++# include ++#endif + + /* + * This file defines and uses a number of different structures: +@@ -865,6 +869,27 @@ static int provider_init(OSSL_PROVIDER * + + if (load_dir == NULL) { + load_dir = ossl_safe_getenv("OPENSSL_MODULES"); ++#ifdef _WIN32 ++ if (load_dir == NULL) { ++ WCHAR execPath[MAX_PATH] = {0}; ++ if( GetModuleFileNameW(NULL, execPath, _countof(execPath)) > 0) ++ { ++ PathCchRemoveFileSpec(execPath, MAX_PATH); ++ PathCchRemoveFileSpec(execPath, MAX_PATH); ++ wcsncat(execPath, L"\\lib\\ossl-modules", MAX_PATH); ++ int len = WideCharToMultiByte(CP_UTF8, 0, execPath, -1, NULL, 0, NULL, NULL); ++ if (len > 0) ++ { ++ allocated_load_dir = OPENSSL_malloc(len); ++ if (WideCharToMultiByte(CP_UTF8, 0, execPath, -1, allocated_load_dir, len, NULL, NULL) == len) ++ { ++ load_dir = allocated_load_dir; ++ } ++ } ++ } ++ } ++#endif ++ + if (load_dir == NULL) + load_dir = MODULESDIR; + }