Skip to content

Commit 1ead11d

Browse files
Allow loading of OpenSSL 3.x native library for Mac, Windows and AIX
1 parent bf3d2d7 commit 1ead11d

File tree

4 files changed

+38
-15
lines changed

4 files changed

+38
-15
lines changed

closed/custom/modules/java.base/Copy.gmk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ ifneq ($(OPENSSL_BUNDLE_LIB_PATH), )
206206
# OpenSSL 1.1.1 on AIX has switched to use archive library files (natural way)
207207
# instead of 'libcrypto.so' files.
208208
# See https://github.com/openssl/openssl/pull/6487.
209-
LIBCRYPTO_NAMES := libcrypto.so.3 libcrypto.so.1.1 libcrypto.so.1.0.0 libcrypto.a
209+
LIBCRYPTO_NAMES := libcrypto64.so.3 libcrypto.so.3 libcrypto.so.1.1 libcrypto.so.1.0.0
210210
else
211211
LIBCRYPTO_NAMES := libcrypto.so
212212
endif

closed/src/java.base/aix/native/libjncrypto/NativeCrypto_md.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* ===========================================================================
3-
* (c) Copyright IBM Corp. 2019, 2022 All Rights Reserved
3+
* (c) Copyright IBM Corp. 2019, 2023 All Rights Reserved
44
* ===========================================================================
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -32,18 +32,34 @@
3232
/* Load the crypto library (return NULL on error) */
3333
void * load_crypto_library(jboolean traceEnabled) {
3434
void * result = NULL;
35+
const char *libname3_a_64 = "libcrypto.a(libcrypto64.so.3)";
36+
const char *libname3_64 = "libcrypto64.so.3";
37+
const char *libname3_a = "libcrypto.a(libcrypto.so.3)";
38+
const char *libname3 = "libcrypto.so.3";
3539
const char *libname111 = "libcrypto.a(libcrypto64.so.1.1)";
3640
const char *libname110 = "libcrypto.so.1.1";
3741
const char *libname102 = "libcrypto.so.1.0.0";
3842
const char *symlink = "libcrypto.a(libcrypto64.so)";
3943

40-
result = dlopen (libname111, RTLD_NOW | RTLD_MEMBER);
44+
result = dlopen (libname3_a_64, RTLD_NOW | RTLD_MEMBER);
4145
if (result == NULL) {
42-
result = dlopen (libname110, RTLD_NOW);
46+
result = dlopen (libname3_64, RTLD_NOW);
4347
if (result == NULL) {
44-
result = dlopen (libname102, RTLD_NOW);
48+
result = dlopen (libname3_a, RTLD_NOW | RTLD_MEMBER);
4549
if (result == NULL) {
46-
result = dlopen (symlink, RTLD_NOW | RTLD_MEMBER);
50+
result = dlopen (libname3, RTLD_NOW);
51+
if (result == NULL) {
52+
result = dlopen (libname111, RTLD_NOW | RTLD_MEMBER);
53+
if (result == NULL) {
54+
result = dlopen (libname110, RTLD_NOW);
55+
if (result == NULL) {
56+
result = dlopen (libname102, RTLD_NOW);
57+
if (result == NULL) {
58+
result = dlopen (symlink, RTLD_NOW | RTLD_MEMBER);
59+
}
60+
}
61+
}
62+
}
4763
}
4864
}
4965
}

closed/src/java.base/macosx/native/libjncrypto/NativeCrypto_md.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* ===========================================================================
3-
* (c) Copyright IBM Corp. 2019, 2022 All Rights Reserved
3+
* (c) Copyright IBM Corp. 2019, 2023 All Rights Reserved
44
* ===========================================================================
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -32,16 +32,20 @@
3232
/* Load the crypto library (return NULL on error) */
3333
void * load_crypto_library(jboolean traceEnabled) {
3434
void * result = NULL;
35-
35+
36+
const char *libname3 = "libcrypto.3.dylib";
3637
const char *libname = "libcrypto.1.1.dylib";
3738
const char *oldname = "libcrypto.1.0.0.dylib";
3839
const char *symlink = "libcrypto.dylib";
3940

40-
result = dlopen (libname, RTLD_NOW);
41+
result = dlopen (libname3, RTLD_NOW);
4142
if (result == NULL) {
42-
result = dlopen (oldname, RTLD_NOW);
43+
result = dlopen (libname, RTLD_NOW);
4344
if (result == NULL) {
44-
result = dlopen (symlink, RTLD_NOW);
45+
result = dlopen (oldname, RTLD_NOW);
46+
if (result == NULL) {
47+
result = dlopen (symlink, RTLD_NOW);
48+
}
4549
}
4650
}
4751

closed/src/java.base/windows/native/libjncrypto/NativeCrypto_md.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* ===========================================================================
3-
* (c) Copyright IBM Corp. 2019, 2022 All Rights Reserved
3+
* (c) Copyright IBM Corp. 2019, 2023 All Rights Reserved
44
* ===========================================================================
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -29,13 +29,16 @@
2929
/* Load the crypto library (return NULL on error) */
3030
void * load_crypto_library(jboolean traceEnabled) {
3131
void * result = NULL;
32+
const char *libname3 = "libcrypto-3-x64.dll";
3233
const char *libname = "libcrypto-1_1-x64.dll";
3334
const char *oldname = "libeay32.dll";
3435

35-
result = LoadLibrary(libname);
36-
36+
result = LoadLibrary(libname3);
3737
if (result == NULL) {
38-
result = LoadLibrary(oldname);
38+
result = LoadLibrary(libname);
39+
if (result == NULL) {
40+
result = LoadLibrary(oldname);
41+
}
3942
}
4043

4144
return result;

0 commit comments

Comments
 (0)