From 9709074f9321cb1ccd69d4fdbc58e65b2ea69b46 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Khan Date: Thu, 15 Aug 2024 14:33:47 -0700 Subject: [PATCH] 1.1 by default --- source/unix/openssl_platform_init.c | 33 +++++++++++++---------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/source/unix/openssl_platform_init.c b/source/unix/openssl_platform_init.c index ea584963..dc761cb5 100644 --- a/source/unix/openssl_platform_init.c +++ b/source/unix/openssl_platform_init.c @@ -494,15 +494,11 @@ static enum aws_libcrypto_version s_resolve_libcrypto_symbols(enum aws_libcrypto } static enum aws_libcrypto_version s_resolve_libcrypto_compile_version(void) { - // TODO: only assert on major and minor? - // TODO: do I need to care about openssl vs aws-lc vs boringssl here? - // TODO: this is not defined in Opensslv3, should I use something else? Probably wrap it in a defined block -#ifdef SHLIB_VERSION_NUMBER - if (strcmp(SHLIB_VERSION_NUMBER, "1.1") == 0) { - return AWS_LIBCRYPTO_1_1_1; - } - if (strcmp(SHLIB_VERSION_NUMBER, "1.0.0") == 0) { +#ifdef OPENSSL_IS_OPENSSL + if (OPENSSL_VERSION_MAJOR == 1 && OPENSSL_VERSION_MINOR == 0) { return AWS_LIBCRYPTO_1_0_2; + } else if(OPENSSL_VERSION_MAJOR == 1 && OPENSSL_VERSION_MINOR == 1) { + return AWS_LIBCRYPTO_1_1_1; } #endif return AWS_LIBCRYPTO_NONE; @@ -549,20 +545,21 @@ static enum aws_libcrypto_version s_resolve_libcrypto_lib(void) { } } - if (compiled_version != AWS_LIBCRYPTO_1_0_2) { - enum aws_libcrypto_version result = s_resolve_libcrypto_lib_impl(AWS_LIBCRYPTO_1_0_2); - if (result == AWS_LIBCRYPTO_1_0_2) { + if (compiled_version != AWS_LIBCRYPTO_1_1_1) { + enum aws_libcrypto_version result = s_resolve_libcrypto_lib_impl(AWS_LIBCRYPTO_1_1_1); + if (result == AWS_LIBCRYPTO_1_1_1) { return result; } } - if (compiled_version != AWS_LIBCRYPTO_1_1_1) { - enum aws_libcrypto_version result = s_resolve_libcrypto_lib_impl(AWS_LIBCRYPTO_1_1_1); - if (result == AWS_LIBCRYPTO_1_1_1) { + if (compiled_version != AWS_LIBCRYPTO_1_0_2) { + enum aws_libcrypto_version result = s_resolve_libcrypto_lib_impl(AWS_LIBCRYPTO_1_0_2); + if (result == AWS_LIBCRYPTO_1_0_2) { return result; } } + AWS_LOGF_DEBUG(AWS_LS_CAL_LIBCRYPTO_RESOLVE, "loading libcrypto.so"); void *module = dlopen("libcrypto.so", RTLD_NOW); if (module) { @@ -652,16 +649,16 @@ static enum aws_libcrypto_version s_resolve_libcrypto(void) { } if (result == AWS_LIBCRYPTO_NONE) { AWS_LOGF_DEBUG(AWS_LS_CAL_LIBCRYPTO_RESOLVE, "did not find boringssl symbols linked"); - result = s_resolve_libcrypto_symbols(AWS_LIBCRYPTO_1_0_2, process); + result = s_resolve_libcrypto_symbols(AWS_LIBCRYPTO_1_1_1, process); } if (result == AWS_LIBCRYPTO_NONE) { - AWS_LOGF_DEBUG(AWS_LS_CAL_LIBCRYPTO_RESOLVE, "did not find libcrypto 1.0.2 symbols linked"); - // result = s_resolve_libcrypto_symbols(AWS_LIBCRYPTO_1_1_1, process); + AWS_LOGF_DEBUG(AWS_LS_CAL_LIBCRYPTO_RESOLVE, "did not find libcrypto 1.1.1 symbols linked"); + result = s_resolve_libcrypto_symbols(AWS_LIBCRYPTO_1_0_2, process); } dlclose(process); if (result == AWS_LIBCRYPTO_NONE) { - AWS_LOGF_DEBUG(AWS_LS_CAL_LIBCRYPTO_RESOLVE, "did not find libcrypto 1.1.1 symbols linked"); + AWS_LOGF_DEBUG(AWS_LS_CAL_LIBCRYPTO_RESOLVE, "did not find libcrypto 1.0.2 symbols linked"); AWS_LOGF_DEBUG( AWS_LS_CAL_LIBCRYPTO_RESOLVE, "libcrypto symbols were not statically linked, searching for shared libraries");