From da3937b852758b361b1ec2b3ae7ac884f203ea1d Mon Sep 17 00:00:00 2001 From: Ahson Khan Date: Wed, 4 Oct 2023 19:01:25 -0700 Subject: [PATCH 1/3] Remove OPENSSL_VERSION_NUMBER version check for the CAPath option in libcurl. --- sdk/core/azure-core/inc/azure/core/http/curl_transport.hpp | 5 +---- sdk/core/azure-core/src/http/curl/curl.cpp | 4 ++-- sdk/core/azure-core/test/ut/curl_options_test.cpp | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/sdk/core/azure-core/inc/azure/core/http/curl_transport.hpp b/sdk/core/azure-core/inc/azure/core/http/curl_transport.hpp index 9e417afcfe..b5cafb46ad 100644 --- a/sdk/core/azure-core/inc/azure/core/http/curl_transport.hpp +++ b/sdk/core/azure-core/inc/azure/core/http/curl_transport.hpp @@ -16,9 +16,6 @@ #if defined(AZ_PLATFORM_LINUX) #include -#if OPENSSL_VERSION_NUMBER >= 0x00905100L -#define _azure_SUPPORT_SETTING_CAPATH -#endif // OPENSSL_VERSION_NUMBER >= 0x00905100L #endif // defined(AZ_PLATFORM_LINUX) namespace Azure { namespace Core { namespace Http { @@ -130,7 +127,7 @@ namespace Azure { namespace Core { namespace Http { */ std::string CAInfo; -#if defined(_azure_SUPPORT_SETTING_CAPATH) +#if defined(AZ_PLATFORM_LINUX) /** * @brief Path to a directory which holds PEM encoded file, containing the certificate * authorities sent to libcurl handle directly. diff --git a/sdk/core/azure-core/src/http/curl/curl.cpp b/sdk/core/azure-core/src/http/curl/curl.cpp index 89b292c7ee..91c1a0164c 100644 --- a/sdk/core/azure-core/src/http/curl/curl.cpp +++ b/sdk/core/azure-core/src/http/curl/curl.cpp @@ -1283,7 +1283,7 @@ inline std::string GetConnectionKey(std::string const& host, CurlTransportOption key.append(","); key.append(!options.CAInfo.empty() ? options.CAInfo : "0"); key.append(","); -#if defined(_azure_SUPPORT_SETTING_CAPATH) +#if defined(AZ_PLATFORM_LINUX) key.append(!options.CAPath.empty() ? options.CAPath : "0"); #else key.append("0"); // CAPath is always empty on Windows; @@ -2320,7 +2320,7 @@ CurlConnection::CurlConnection( } } -#if defined(_azure_SUPPORT_SETTING_CAPATH) +#if defined(AZ_PLATFORM_LINUX) if (!options.CAPath.empty()) { if (!SetLibcurlOption(m_handle, CURLOPT_CAPATH, options.CAPath.c_str(), &result)) diff --git a/sdk/core/azure-core/test/ut/curl_options_test.cpp b/sdk/core/azure-core/test/ut/curl_options_test.cpp index 7de70883ab..9de0e7d5c1 100644 --- a/sdk/core/azure-core/test/ut/curl_options_test.cpp +++ b/sdk/core/azure-core/test/ut/curl_options_test.cpp @@ -235,7 +235,7 @@ namespace Azure { namespace Core { namespace Test { .ConnectionPoolIndex.clear()); } -#if defined(_azure_SUPPORT_SETTING_CAPATH) +#if defined(AZ_PLATFORM_LINUX) TEST(CurlTransportOptions, setCADirectory) { Azure::Core::Http::CurlTransportOptions curlOptions; @@ -267,7 +267,7 @@ namespace Azure { namespace Core { namespace Test { std::unique_ptr response; EXPECT_NO_THROW(response = pipeline.Send(request, Azure::Core::Context::ApplicationContext)); - EXPECT_EQ(response->GetStatusCode(), Azure::Core::Http::HttpStatusCode::Ok); + EXPECT_NE(response->GetStatusCode(), Azure::Core::Http::HttpStatusCode::Ok); // Clean the connection from the pool *Windows fails to clean if we leave to be clean upon // app-destruction From b8a2f279371f3580c4a951229c73574d1351d6bf Mon Sep 17 00:00:00 2001 From: Ahson Khan Date: Wed, 4 Oct 2023 19:08:05 -0700 Subject: [PATCH 2/3] Revert unit test change that caused an intentional error. --- sdk/core/azure-core/test/ut/curl_options_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/core/azure-core/test/ut/curl_options_test.cpp b/sdk/core/azure-core/test/ut/curl_options_test.cpp index 9de0e7d5c1..28d6c4459c 100644 --- a/sdk/core/azure-core/test/ut/curl_options_test.cpp +++ b/sdk/core/azure-core/test/ut/curl_options_test.cpp @@ -267,7 +267,7 @@ namespace Azure { namespace Core { namespace Test { std::unique_ptr response; EXPECT_NO_THROW(response = pipeline.Send(request, Azure::Core::Context::ApplicationContext)); - EXPECT_NE(response->GetStatusCode(), Azure::Core::Http::HttpStatusCode::Ok); + EXPECT_EQ(response->GetStatusCode(), Azure::Core::Http::HttpStatusCode::Ok); // Clean the connection from the pool *Windows fails to clean if we leave to be clean upon // app-destruction From 696aef78952ddb57f5205445b6ea90afee553f6d Mon Sep 17 00:00:00 2001 From: Ahson Khan Date: Thu, 5 Oct 2023 13:04:48 -0700 Subject: [PATCH 3/3] Remove the openssl header. --- sdk/core/azure-core/inc/azure/core/http/curl_transport.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sdk/core/azure-core/inc/azure/core/http/curl_transport.hpp b/sdk/core/azure-core/inc/azure/core/http/curl_transport.hpp index b5cafb46ad..0ff2719646 100644 --- a/sdk/core/azure-core/inc/azure/core/http/curl_transport.hpp +++ b/sdk/core/azure-core/inc/azure/core/http/curl_transport.hpp @@ -14,10 +14,6 @@ #include "azure/core/http/transport.hpp" #include "azure/core/platform.hpp" -#if defined(AZ_PLATFORM_LINUX) -#include -#endif // defined(AZ_PLATFORM_LINUX) - namespace Azure { namespace Core { namespace Http { class CurlNetworkConnection;