From 8e802f324f5547343206690a0ae69e40cbc29de8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szczepan=20=C4=86wikli=C5=84ski?= Date: Wed, 4 Feb 2026 20:05:46 +0100 Subject: [PATCH 1/5] FreeBSD: Add suffix numbering for OpenSSL3.5 --- .../libs/System.Security.Cryptography.Native/opensslshim.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/native/libs/System.Security.Cryptography.Native/opensslshim.c b/src/native/libs/System.Security.Cryptography.Native/opensslshim.c index 8d48552136b61e..83b5039069952c 100644 --- a/src/native/libs/System.Security.Cryptography.Native/opensslshim.c +++ b/src/native/libs/System.Security.Cryptography.Native/opensslshim.c @@ -142,6 +142,12 @@ static void OpenLibraryOnce(void) DlOpen(MAKELIB("30")); } + if (libssl == NULL) + { + // OpenSSL 3.5 from base as found in FreeBSD 15.0 + DlOpen(MAKELIB("35")); + } + // Fallbacks for OpenSSL 1.1.x if (libssl == NULL) { From 0bea061e55574d4007de85beb61e1b6284314581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szczepan=20=C4=86wikli=C5=84ski?= Date: Wed, 4 Feb 2026 21:02:35 +0100 Subject: [PATCH 2/5] Rework order --- .../System.Security.Cryptography.Native/opensslshim.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/native/libs/System.Security.Cryptography.Native/opensslshim.c b/src/native/libs/System.Security.Cryptography.Native/opensslshim.c index 83b5039069952c..1e325b7d98c856 100644 --- a/src/native/libs/System.Security.Cryptography.Native/opensslshim.c +++ b/src/native/libs/System.Security.Cryptography.Native/opensslshim.c @@ -138,14 +138,14 @@ static void OpenLibraryOnce(void) if (libssl == NULL) { - // OpenSSL 3.0 from base as found in FreeBSD 14.0 - DlOpen(MAKELIB("30")); - } + // OpenSSL 3.5 from base as found in FreeBSD 15.0 + DlOpen(MAKELIB("35")); + } if (libssl == NULL) { - // OpenSSL 3.5 from base as found in FreeBSD 15.0 - DlOpen(MAKELIB("35")); + // OpenSSL 3.0 from base as found in FreeBSD 14.0 + DlOpen(MAKELIB("30")); } // Fallbacks for OpenSSL 1.1.x From 93d5d594d377ae0fcf976e48fe1f06e42df4335f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szczepan=20=C4=86wikli=C5=84ski?= Date: Wed, 4 Feb 2026 21:06:48 +0100 Subject: [PATCH 3/5] Check for 3.5 from ports also --- .../libs/System.Security.Cryptography.Native/opensslshim.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/native/libs/System.Security.Cryptography.Native/opensslshim.c b/src/native/libs/System.Security.Cryptography.Native/opensslshim.c index 1e325b7d98c856..992f21e75acc9f 100644 --- a/src/native/libs/System.Security.Cryptography.Native/opensslshim.c +++ b/src/native/libs/System.Security.Cryptography.Native/opensslshim.c @@ -130,6 +130,12 @@ static void OpenLibraryOnce(void) #ifdef __FreeBSD__ // The ports version of OpenSSL is used over base where possible + if (libssl == NULL) + { + // OpenSSL 3.5 from ports + DlOpen(MAKELIB("17")); + } + if (libssl == NULL) { // OpenSSL 3.0 from ports From eb590851cbf2256fd240f20a2bda4269b1023ee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szczepan=20=C4=86wikli=C5=84ski?= Date: Thu, 5 Feb 2026 11:45:45 +0100 Subject: [PATCH 4/5] Order change, moved check into top level if --- .../opensslshim.c | 55 +++++++++---------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/src/native/libs/System.Security.Cryptography.Native/opensslshim.c b/src/native/libs/System.Security.Cryptography.Native/opensslshim.c index 992f21e75acc9f..58cf9dc8014bff 100644 --- a/src/native/libs/System.Security.Cryptography.Native/opensslshim.c +++ b/src/native/libs/System.Security.Cryptography.Native/opensslshim.c @@ -95,77 +95,74 @@ static void OpenLibraryOnce(void) // Android OpenSSL has no soname DlOpen(LIBNAME); } -#endif - +#elif defined __FreeBSD__ + // The ports version of OpenSSL is used over base where possible if (libssl == NULL) { - // Prefer OpenSSL 3.x - DlOpen(MAKELIB("3")); + // OpenSSL 3.5 from ports + DlOpen(MAKELIB("17")); } if (libssl == NULL) { - DlOpen(MAKELIB("1.1")); + // OpenSSL 3.5 from base as found in FreeBSD 15.0 + DlOpen(MAKELIB("35")); } if (libssl == NULL) { - // Debian 9 has dropped support for SSLv3 and so they have bumped their soname. Let's try it - // before trying the version 1.0.0 to make it less probable that some of our other dependencies - // end up loading conflicting version of libssl. - DlOpen(MAKELIB("1.0.2")); + // OpenSSL 3.0 from ports + DlOpen(MAKELIB("12")); } if (libssl == NULL) { - // Now try the default versioned so naming as described in the OpenSSL doc - DlOpen(MAKELIB("1.0.0")); + // OpenSSL 3.0 from base as found in FreeBSD 14.0 + DlOpen(MAKELIB("30")); } + // Fallbacks for OpenSSL 1.1.x if (libssl == NULL) { - // Fedora derived distros use different naming for the version 1.0.0 - DlOpen(MAKELIB("10")); + DlOpen(MAKELIB("11")); } -#ifdef __FreeBSD__ - // The ports version of OpenSSL is used over base where possible if (libssl == NULL) { - // OpenSSL 3.5 from ports - DlOpen(MAKELIB("17")); + DlOpen(MAKELIB("111")); } +#endif if (libssl == NULL) { - // OpenSSL 3.0 from ports - DlOpen(MAKELIB("12")); + // Prefer OpenSSL 3.x + DlOpen(MAKELIB("3")); } if (libssl == NULL) { - // OpenSSL 3.5 from base as found in FreeBSD 15.0 - DlOpen(MAKELIB("35")); - } + DlOpen(MAKELIB("1.1")); + } if (libssl == NULL) { - // OpenSSL 3.0 from base as found in FreeBSD 14.0 - DlOpen(MAKELIB("30")); + // Debian 9 has dropped support for SSLv3 and so they have bumped their soname. Let's try it + // before trying the version 1.0.0 to make it less probable that some of our other dependencies + // end up loading conflicting version of libssl. + DlOpen(MAKELIB("1.0.2")); } - // Fallbacks for OpenSSL 1.1.x if (libssl == NULL) { - DlOpen(MAKELIB("11")); + // Now try the default versioned so naming as described in the OpenSSL doc + DlOpen(MAKELIB("1.0.0")); } if (libssl == NULL) { - DlOpen(MAKELIB("111")); + // Fedora derived distros use different naming for the version 1.0.0 + DlOpen(MAKELIB("10")); } -#endif - } static pthread_once_t g_openLibrary = PTHREAD_ONCE_INIT; From b9428a8d9ccb8c15203fd13f826a3cbd00cf3f43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szczepan=20=C4=86wikli=C5=84ski?= Date: Thu, 5 Feb 2026 11:47:43 +0100 Subject: [PATCH 5/5] Fix. --- .../libs/System.Security.Cryptography.Native/opensslshim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/libs/System.Security.Cryptography.Native/opensslshim.c b/src/native/libs/System.Security.Cryptography.Native/opensslshim.c index 58cf9dc8014bff..28d1a0ccf0bb2c 100644 --- a/src/native/libs/System.Security.Cryptography.Native/opensslshim.c +++ b/src/native/libs/System.Security.Cryptography.Native/opensslshim.c @@ -95,7 +95,7 @@ static void OpenLibraryOnce(void) // Android OpenSSL has no soname DlOpen(LIBNAME); } -#elif defined __FreeBSD__ +#elif defined(__FreeBSD__) // The ports version of OpenSSL is used over base where possible if (libssl == NULL) {