Skip to content

Commit

Permalink
in secure mode, don't append the port to the Host header
Browse files Browse the repository at this point in the history
because both calc_cn_host in cpprestsdk/Release/src/http/client/http_client_asio.cpp
and winhttp_client::send_request in cpprestsdk/Release/src/http/client/http_client_winhttp.cpp
compare the entire Host header value with the certificate Common Name
which causes an SSL handshake error
  • Loading branch information
lo-simon authored and garethsb committed Feb 22, 2024
1 parent 638d40a commit e934feb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Development/nmos/client_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,17 @@ namespace nmos
if (!base_uri.user_info().empty())
{
auto host = base_uri.user_info();
if (base_uri.port() > 0)

// hmm, in secure mode, don't append the port to the Host header
// because both calc_cn_host in cpprestsdk/Release/src/http/client/http_client_asio.cpp
// and winhttp_client::send_request in cpprestsdk/Release/src/http/client/http_client_winhttp.cpp
// compare the entire Host header value with the certificate Common Name
// which causes an SSL handshake error
if (base_uri.port() > 0 && !web::is_secure_uri_scheme(base_uri.scheme()))
{
host.append(U(":")).append(utility::conversions::details::to_string_t(base_uri.port()));
}

client->add_handler([host](web::http::http_request request, std::shared_ptr<web::http::http_pipeline_stage> next_stage) -> pplx::task<web::http::http_response>
{
request.headers().add(web::http::header_names::host, host);
Expand Down

0 comments on commit e934feb

Please sign in to comment.