Skip to content
This repository was archived by the owner on Jun 1, 2026. It is now read-only.

Implement host override of CN checking in the ASIO backend#832

Merged
ras0219-msft merged 6 commits into
microsoft:masterfrom
BillyONeal:asio
Aug 15, 2018
Merged

Implement host override of CN checking in the ASIO backend#832
ras0219-msft merged 6 commits into
microsoft:masterfrom
BillyONeal:asio

Conversation

@BillyONeal
Copy link
Copy Markdown
Member

Add new function calc_cn_host which applies our host header override policy.
Add the CN hostname used to asio_connection. Change the protocol such that the SSL upgrade request needs to come with the target hostname to use.
Replace std::deque in connection pooling with a version that has constant amortized time per insertion. (std::deque is only constant amortized time for insertions in terms of element operations, not overall). Factor out the replacement policy from the overall pool machinery.
Change release() to take shared_ptr&& to make sure the caller has let go.
Enable verify_cert_chain_platform_specific on Windows; otherwise OpenSSL says that the root CAs are untrusted and all SSL tests fail on Windows.
This accidentially repairs these test cases on Windows:
**** outside_tests:outside_wikipedia_compressed_http_response FAILED ****
**** outside_tests:multiple_https_requests FAILED ****
**** outside_tests:outside_ssl_json FAILED ****

Add new function calc_cn_host which applies our host header override policy.
Add the CN hostname used to asio_connection. Change the protocol such that the SSL upgrade request needs to come with the target hostname to use.
Replace std::deque in connection pooling with a version that has constant amortized time per insertion. (std::deque is only constant amortized time for insertions in terms of element operations, not overall). Factor out the replacement policy from the overall pool machinery.
Change release() to take shared_ptr&& to make sure the caller has let go.
Enable verify_cert_chain_platform_specific on Windows; otherwise OpenSSL says that the root CAs are untrusted and all SSL tests fail on Windows.
  This accidentially repairs these test cases on Windows:
  **** outside_tests:outside_wikipedia_compressed_http_response FAILED ****
  **** outside_tests:multiple_https_requests FAILED ****
  **** outside_tests:outside_ssl_json FAILED ****
}
m_ssl_stream = utility::details::make_unique<boost::asio::ssl::stream<boost::asio::ip::tcp::socket&>>(
m_socket, ssl_context);
m_cn_hostname = cn_hostname;
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.

std::move()

}
catch (...)
{
// if we didn't have enough memory to pool the connection, give up and drop it on the
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.

We don't handle OOM, so this is unneeded.

{
start_epoch_interval(shared_from_this());
is_timer_running = true;
return;
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.

Needs a auto dropped = std::move(connection);

#ifdef CPPREST_PLATFORM_ASIO_CERT_VERIFICATION_AVAILABLE
, m_openssl_failed(false)
#endif
#endif // CPPREST_USE_PLATFORM_VERIFICATION
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.

Comment doesn't match #ifdef

return verify_cert_chain_platform_specific(verifyCtx, m_connection->cn_hostname());
}
#endif
#endif // CPPREST_USE_PLATFORM_VERIFICATION
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.

Comment doesn't match #ifdef

#ifdef CPPREST_PLATFORM_ASIO_CERT_VERIFICATION_AVAILABLE
bool m_openssl_failed;
#endif
#endif // CPPREST_USE_PLATFORM_VERIFICATION
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.

Comment doesn't match #ifdef

}

m_availableConnections.swap(m_returnedConnections);
std::reverse(m_availableConnections.begin(), m_availableConnections.end());
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.

This should be LIFO to emphasize hot connections.

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.

Consider renaming m_coldConnections to m_high_water_mark

}

void release(const std::shared_ptr<asio_connection>& connection)
void release(std::shared_ptr<asio_connection>&& connection)
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.

The timer needs to be restarted if it isn't running.

@ras0219-msft ras0219-msft merged commit 4e19c0c into microsoft:master Aug 15, 2018
const web::http::http_headers& requestHeaders)
{
std::string result;
if (secure)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

returns empty string when !secure

@BillyONeal
Copy link
Copy Markdown
Member Author

BillyONeal commented Aug 17, 2018 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants