This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch crypto-174
in repository https://gitbox.apache.org/repos/asf/commons-crypto.git


The following commit(s) were added to refs/heads/crypto-174 by this push:
     new db284325 Crypto 174 (#268)
db284325 is described below

commit db28432515cf8c59541ad17deb6ddb79e6139dd9
Author: sebbASF <[email protected]>
AuthorDate: Wed Nov 8 00:57:15 2023 +0000

    Crypto 174 (#268)
    
    * Don't try to convert libraryPath
    
    * Fix up Windows defines
---
 .github/workflows/maven.yml                              | 16 +++++++---------
 .../native/org/apache/commons/crypto/DynamicLoader.c     |  5 +----
 2 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index 4fe5c748..22f02cf2 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -91,22 +91,20 @@ jobs:
     - name: OpenSSL engine (windows)
       # need to override the libarary on windows
       if: ${{ matrix.os == 'windows-latest' }}
-      # e.g. ENGINESDIR: "C:\Program Files\OpenSSL\lib\engines-1_1"
-      # The code below extracts "C:\Program Files\OpenSSL\lib", as expected
-      # but this does not seem to be the correct setting to override system 
library
-      # To avoid failing tests unnecessarily, skip the check for OpenSSL in 
the library name
-      # To be resolved...
-      # N.B. This must *not* be run under the bash shell, as that changes the 
default openssl library
+      # e.g. NAME: "libcrypto-1_1-x64.dll"
+      # Not sure how to derive this automatically
       run: |
         openssl version -a
-        chcp 65001 #set code page to utf-8
-        echo ((openssl version -e) -replace ': "','=' -replace 
'\\engines-.*','') >> $env:GITHUB_ENV
+        echo "NAME=libcrypto-1_1-x64.dll" >> $env:GITHUB_ENV
         echo "CHECK_SKIP=skip" >> $env:GITHUB_ENV
     # N.B. '-V -B -ntp' is shorthand for '--show-version --batch-mode 
--no-transfer-progress'
     # 
     # The bash shell under Windows changes the openssl default library, so is 
not used for running tests
     # Unfortunately that means separate steps for Windows, as it uses a 
different syntax for referrring to
     # environment variables: $env:VARNAME instead of $VARNAME
+    # Also, note that Windows stores all the DLLs in the same directory.
+    # Instead of defining jni.library.path and jna.library.path we need to 
define
+    # jni.library.name and commons.crypto.OpenSslNativeJna to override the 
file names
     - name: Build with Maven (Windows)
       if: ${{ matrix.os == 'windows-latest' }}
       # OPENSSL_HOME is needed for Windows build to find some header files
@@ -119,7 +117,7 @@ jobs:
       env:
         OPENSSL_HOME: "C:\\Miniconda\\Library"
       run: |
-        mvn -V -B -ntp -DtrimStackTrace=false 
-D"jni.library.path=$env:ENGINESDIR" -D"jna.library.path=$env:ENGINESDIR" 
-D"commons.crypto.openssl.check=$env:CHECK_SKIP"
+        mvn -V -B -ntp -DtrimStackTrace=false -D"jni.library.name=$env:NAME" 
-D"commons.crypto.OpenSslNativeJna=$env:NAME" 
-D"commons.crypto.openssl.check=$env:CHECK_SKIP"
     - name: Build with Maven (not Windows)
       if: ${{ matrix.os != 'windows-latest' }}
       run: |
diff --git a/src/main/native/org/apache/commons/crypto/DynamicLoader.c 
b/src/main/native/org/apache/commons/crypto/DynamicLoader.c
index 57fff14a..1f265627 100644
--- a/src/main/native/org/apache/commons/crypto/DynamicLoader.c
+++ b/src/main/native/org/apache/commons/crypto/DynamicLoader.c
@@ -44,10 +44,7 @@ HMODULE open_library(JNIEnv *env)
 #endif
 
 #ifdef WINDOWS
-    size_t liblen = strlen(libraryPath) + 1;
-    wchar_t* lib = (wchar_t *)malloc(liblen);
-    mbstowcs(lib, libraryPath, liblen); // convert for Windows call
-    openssl = LoadLibrary(lib);
+    openssl = LoadLibraryA(libraryPath); // use the non-generic method; assume 
libraryPath is suitable
 #endif
 
     //   Did we succeed?

Reply via email to