Fix Windows error for failing curl SSL cache (#6582)

* Fix Windows error for failing curl SSL cache

* Fix unused parameter warning in win_http_transport.cpp, as in #6579

* Update changelog, cspell, and conditional init m_sslShareHandle

---------

Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>
This commit is contained in:
Sushrut Shringarputale 2025-05-20 21:59:01 -07:00 committed by GitHub
parent 8ce6da8645
commit c6d553b2a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 10 deletions

1
.vscode/cspell.json vendored
View File

@ -263,6 +263,7 @@
"stoull",
"STREQ",
"Sushrut",
"sushshring",
"Sutou",
"testid",
"swedencentral",

View File

@ -4,7 +4,7 @@
### Features Added
- [[#6535]](https://github.com/Azure/azure-sdk-for-cpp/issues/6535) Enable SSL caching for libcurl transport by default, which is backwards compatible behavior with older libcurl versions, so using the default settings won't result in transport error when using libcurl >= 8.12. The option is controlled by `CurlTransportOptions::EnableCurlSslCaching`, and is on by default. (A community contribution, courtesy of _[chewi](https://github.com/sushshring)_)
- [[#6535]](https://github.com/Azure/azure-sdk-for-cpp/issues/6535) Enable SSL caching for libcurl transport by default, which is backwards compatible behavior with older libcurl versions, so using the default settings won't result in transport error when using libcurl >= 8.12. The option is controlled by `CurlTransportOptions::EnableCurlSslCaching`, and is on by default. (A community contribution, courtesy of _[sushshring](https://github.com/sushshring)_)
### Breaking Changes

View File

@ -2314,14 +2314,6 @@ CurlConnection::CurlConnection(
}
CURLcode result;
m_sslShareHandle = std::make_unique<Azure::Core::_detail::CURLSHWrapper>();
if (!m_sslShareHandle->share_handle)
{
throw Azure::Core::Http::TransportException(
_detail::DefaultFailedToGetNewConnectionTemplate + hostDisplayName + ". "
+ std::string("curl_share_init returned Null"));
}
if (!options.EnableCurlSslCaching)
{
// Disable SSL session ID caching
@ -2334,6 +2326,15 @@ CurlConnection::CurlConnection(
}
else
{
m_sslShareHandle = std::make_unique<Azure::Core::_detail::CURLSHWrapper>();
if (!m_sslShareHandle->share_handle)
{
throw Azure::Core::Http::TransportException(
_detail::DefaultFailedToGetNewConnectionTemplate + hostDisplayName + ". "
+ std::string("curl_share_init returned Null"));
}
CURLSHcode shResult;
if (!SetLibcurlShareOption(
m_sslShareHandle, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION, &shResult))
@ -2343,7 +2344,7 @@ CurlConnection::CurlConnection(
+ std::string(curl_share_strerror(shResult)));
}
if (!SetLibcurlOption(m_handle, CURLOPT_SHARE, m_sslShareHandle.get(), &result))
if (!SetLibcurlOption(m_handle, CURLOPT_SHARE, m_sslShareHandle->share_handle, &result))
{
throw Azure::Core::Http::TransportException(
_detail::DefaultFailedToGetNewConnectionTemplate + hostDisplayName + ". "

View File

@ -1670,6 +1670,10 @@ namespace Azure { namespace Core { namespace Http { namespace _detail {
std::unique_ptr<RawResponse> WinHttpRequest::SendRequestAndGetResponse(HttpMethod requestMethod)
{
// Suppress unused parameter warning (C4100).
// Keeping 'requestMethod' in the signature preserves API compatibility.
(void)requestMethod;
// First, use WinHttpQueryHeaders to obtain the size of the buffer.
// The call is expected to fail since no destination buffer is provided.
DWORD sizeOfHeaders = 0;