From 309009e85f417b379673c797abc482ba1d902783 Mon Sep 17 00:00:00 2001 From: Thefrank <1910378+Thefrank@users.noreply.github.com> Date: Fri, 8 Mar 2024 09:54:20 -0700 Subject: [PATCH] FreeBSD: Add suffix numbering for OpenSSL3 --- .../opensslshim.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/native/libs/System.Security.Cryptography.Native/opensslshim.c b/src/native/libs/System.Security.Cryptography.Native/opensslshim.c index d21d6273410119..cd3e5f46b87da6 100644 --- a/src/native/libs/System.Security.Cryptography.Native/opensslshim.c +++ b/src/native/libs/System.Security.Cryptography.Native/opensslshim.c @@ -116,8 +116,21 @@ static void OpenLibraryOnce(void) DlOpen(MAKELIB("10")); } - // FreeBSD uses a different suffix numbering convention. - // Current supported FreeBSD releases should use the order .11 -> .111 +#ifdef __FreeBSD__ + // The ports version of OpenSSL is used over base where possible + if (libssl == NULL) + { + // OpenSSL 3.0 from ports + DlOpen(MAKELIB("12")); + } + + if (libssl == NULL) + { + // OpenSSL 3.0 from base as found in FreeBSD 14.0 + DlOpen(MAKELIB("30")); + } + + // Fallbacks for OpenSSL 1.1.x if (libssl == NULL) { DlOpen(MAKELIB("11")); @@ -127,6 +140,8 @@ static void OpenLibraryOnce(void) { DlOpen(MAKELIB("111")); } +#endif + } static pthread_once_t g_openLibrary = PTHREAD_ONCE_INIT;