Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ namespace Azure { namespace Core { namespace Http {
*/
struct WinHttpTransportOptions final
{
// Empty struct reserved for future options.
/**
* @brief When `true`, allows an invalid certificate authority. If this flag is set, the
* application does not receive a WINHTTP_CALLBACK_STATUS_FLAG_INVALID_CA callback.
*/
bool IgnoreUnknownServerCert = false;
Comment thread
LarryOsterman marked this conversation as resolved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we avoid abbreviations and use IgnoreUnknownCertificateAuthority?

nit: What should the reader infer from server here in the name?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a TLS 1.2 connection, there are two possible certificates: The server certificate and the client certificate. The server validates the client certificate, and the client validates the server certificate. This variable controls the validation of the server certificate, so it makes sense to me that the variable name should probably include "Server", since there is some level of ambiguity present.

Having said that, the variable doesn't control if it ignores an unknown server certificate, instead as you mentioned, the flag controls if an unknown CA should be allowed, which is somewhat different (a server certificate could be invalid if (for instance) the subject didn't match the IP address of the server - this flag doesn't disable that check).

};

/**
Expand Down
10 changes: 10 additions & 0 deletions sdk/core/azure-core/src/http/winhttp/win_http_transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,16 @@ void WinHttpTransport::CreateRequestHandle(std::unique_ptr<_detail::HandleManage
GetErrorAndThrow("Error while setting client cert context to ignore..");
}
}

if (m_options.IgnoreUnknownServerCert)
{
auto option = SECURITY_FLAG_IGNORE_UNKNOWN_CA;
if (!WinHttpSetOption(
handleManager->m_requestHandle, WINHTTP_OPTION_SECURITY_FLAGS, &option, sizeof(option)))
{
GetErrorAndThrow("Error while setting ignore unknown server certificate..");
}
}
}

// For PUT/POST requests, send additional data using WinHttpWriteData.
Expand Down
5 changes: 0 additions & 5 deletions sdk/core/perf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,3 @@ create_map_file(azure-perf azure-perf.map)
set_target_properties(azure-perf PROPERTIES FOLDER "Core")

add_subdirectory(test)

# Give a warning about winHTTP and insecure
if(BUILD_TRANSPORT_WINHTTP)
message(WARNING "Note. WInHTTP does not support running performance tests with `insecure` mode enabled. Use libcurl transport adapter if you want to use insecure mode. ")
endif()
14 changes: 10 additions & 4 deletions sdk/core/perf/src/base_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#if defined(BUILD_CURL_HTTP_TRANSPORT_ADAPTER)
#include <azure/core/http/curl_transport.hpp>
#endif
#if defined(BUILD_TRANSPORT_WINHTTP_ADAPTER)
#include <azure/core/http/win_http_transport.hpp>
#endif
#include <azure/core/http/policies/policy.hpp>
#include <azure/core/internal/http/pipeline.hpp>

Expand Down Expand Up @@ -102,18 +105,21 @@ namespace Azure { namespace Perf {

void BaseTest::ConfigureInsecureOptions(Azure::Core::_internal::ClientOptions* clientOptions)
Comment thread
LarryOsterman marked this conversation as resolved.
Outdated
Comment thread
vhvb1989 marked this conversation as resolved.
Outdated
{
// NOTE: perf-fm is injecting the SSL config and transport here for the client options
// If the test overrides the options/transport, this can be undone.
#if defined(BUILD_CURL_HTTP_TRANSPORT_ADAPTER)
if (m_isInsecureEnabled)
{
// There's currently no way to ask winHTTP to do insecure SSL.
// Perf test must use libcurl transport until winHTTP can support this.
// NOTE: perf-fm is injecting the SSL config and transport here for the client options
// If the test overrides the options/transport, this can be undone.
Azure::Core::Http::CurlTransportOptions curlOptions;
curlOptions.SslVerifyPeer = false;
clientOptions->Transport.Transport
= std::make_shared<Azure::Core::Http::CurlTransport>(curlOptions);
}
#elif defined(BUILD_TRANSPORT_WINHTTP_ADAPTER)
Azure::Core::Http::WinHttpTransportOptions winHttpOptions;
winHttpOptions.IgnoreUnknownServerCert = true;
clientOptions->Transport.Transport
= std::make_shared<Azure::Core::Http::WinHttpTransport>(winHttpOptions);
#else
// avoid the variable not used warning
(void)clientOptions;
Expand Down
3 changes: 0 additions & 3 deletions sdk/core/perf/src/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,6 @@ void Azure::Perf::Program::Run(
}
if (options.Insecure)
{
#if defined(BUILD_TRANSPORT_WINHTTP_ADAPTER)
std::cout << std::endl << " ERROR !!! winHTTP does not support using insecure mode.";
#endif
parallelTest[i]->SetInsecureEnabled(true);
Comment thread
LarryOsterman marked this conversation as resolved.
Outdated
}
}
Expand Down