From 9f89c3bf7c68891f17bba17d252d342a09ecc6e7 Mon Sep 17 00:00:00 2001 From: Thefrank <1910378+Thefrank@users.noreply.github.com> Date: Sat, 13 Jan 2024 13:10:53 -0700 Subject: [PATCH 1/3] FreeBSD: Add suffix numbering for OpenSSL3 --- .../System.Security.Cryptography.Native/opensslshim.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/native/libs/System.Security.Cryptography.Native/opensslshim.c b/src/native/libs/System.Security.Cryptography.Native/opensslshim.c index d21d6273410119..a08c1aa90f3271 100644 --- a/src/native/libs/System.Security.Cryptography.Native/opensslshim.c +++ b/src/native/libs/System.Security.Cryptography.Native/opensslshim.c @@ -127,6 +127,17 @@ static void OpenLibraryOnce(void) { DlOpen(MAKELIB("111")); } + // FreeBSD uses this for OpenSSL3 from ports. OpenSSL3.1 would be "13" + // Ports version of OpenSSL is used over base where possible + if (libssl == NULL) + { + DlOpen(MAKELIB("12")); + } + // FreeBSD uses this for OpenSSL3 from base as found in FreeBSD 14.0 + if (libssl == NULL) + { + DlOpen(MAKELIB("30")); + } } static pthread_once_t g_openLibrary = PTHREAD_ONCE_INIT; From 587086e1879e4b0dd60ae2f5c6070030578d9af6 Mon Sep 17 00:00:00 2001 From: Thefrank <1910378+Thefrank@users.noreply.github.com> Date: Sun, 14 Jan 2024 20:39:18 -0700 Subject: [PATCH 2/3] Feedback from review --- .../opensslshim.c | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/native/libs/System.Security.Cryptography.Native/opensslshim.c b/src/native/libs/System.Security.Cryptography.Native/opensslshim.c index a08c1aa90f3271..895f203eef32db 100644 --- a/src/native/libs/System.Security.Cryptography.Native/opensslshim.c +++ b/src/native/libs/System.Security.Cryptography.Native/opensslshim.c @@ -116,27 +116,29 @@ static void OpenLibraryOnce(void) DlOpen(MAKELIB("10")); } - // FreeBSD uses a different suffix numbering convention. - // Current supported FreeBSD releases should use the order .11 -> .111 + // FreeBSD uses a different suffix numbering convention + // The ports version of OpenSSL is used over base where possible if (libssl == NULL) { - DlOpen(MAKELIB("11")); + // FreeBSD uses .12 for OpenSSL 3.0 from ports + DlOpen(MAKELIB("12")); } if (libssl == NULL) { - DlOpen(MAKELIB("111")); + // FreeBSD uses .30 for OpenSSL 3.0 from base as found in FreeBSD 14.0 + DlOpen(MAKELIB("30")); } - // FreeBSD uses this for OpenSSL3 from ports. OpenSSL3.1 would be "13" - // Ports version of OpenSSL is used over base where possible + + // FreeBSD OpenSSL 1.1.x are numbered below if (libssl == NULL) { - DlOpen(MAKELIB("12")); + DlOpen(MAKELIB("11")); } - // FreeBSD uses this for OpenSSL3 from base as found in FreeBSD 14.0 + if (libssl == NULL) { - DlOpen(MAKELIB("30")); + DlOpen(MAKELIB("111")); } } From 9e83514c2180f4b86ed1d65adbe9cde11dd2f5be Mon Sep 17 00:00:00 2001 From: Thefrank <1910378+Thefrank@users.noreply.github.com> Date: Mon, 15 Jan 2024 12:55:55 -0700 Subject: [PATCH 3/3] ifdef for FreeBSD --- .../System.Security.Cryptography.Native/opensslshim.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/native/libs/System.Security.Cryptography.Native/opensslshim.c b/src/native/libs/System.Security.Cryptography.Native/opensslshim.c index 895f203eef32db..cd3e5f46b87da6 100644 --- a/src/native/libs/System.Security.Cryptography.Native/opensslshim.c +++ b/src/native/libs/System.Security.Cryptography.Native/opensslshim.c @@ -116,21 +116,21 @@ static void OpenLibraryOnce(void) DlOpen(MAKELIB("10")); } - // FreeBSD uses a different suffix numbering convention +#ifdef __FreeBSD__ // The ports version of OpenSSL is used over base where possible if (libssl == NULL) { - // FreeBSD uses .12 for OpenSSL 3.0 from ports + // OpenSSL 3.0 from ports DlOpen(MAKELIB("12")); } if (libssl == NULL) { - // FreeBSD uses .30 for OpenSSL 3.0 from base as found in FreeBSD 14.0 + // OpenSSL 3.0 from base as found in FreeBSD 14.0 DlOpen(MAKELIB("30")); } - // FreeBSD OpenSSL 1.1.x are numbered below + // Fallbacks for OpenSSL 1.1.x if (libssl == NULL) { DlOpen(MAKELIB("11")); @@ -140,6 +140,8 @@ static void OpenLibraryOnce(void) { DlOpen(MAKELIB("111")); } +#endif + } static pthread_once_t g_openLibrary = PTHREAD_ONCE_INIT;