Skip to content

Commit

Permalink
Avoid sending proxy authorization when ssl tunnel is done
Browse files Browse the repository at this point in the history
  • Loading branch information
philippeVerney committed Feb 22, 2024
1 parent 7bbf5e4 commit e7de2a4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/etp/AbstractClientSessionCRTP.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ namespace ETP_NS
{
m.insert(boost::beast::http::field::sec_websocket_protocol, "etp12.energistics.org");
m.insert(boost::beast::http::field::authorization, etpServerAuthorization);
m.insert(boost::beast::http::field::proxy_authorization, proxyAuthorization);
if (!proxyHost.empty() && !isTls()) {
m.insert(boost::beast::http::field::proxy_authorization, proxyAuthorization);
}
m.insert("etp-encoding", "binary");
for (const auto& mapEntry : additionalHandshakeHeaderFields_) {
m.insert(mapEntry.first, mapEntry.second);
Expand All @@ -60,7 +62,9 @@ namespace ETP_NS
{
m.insert(boost::beast::http::field::sec_websocket_protocol, "etp12.energistics.org");
m.insert(boost::beast::http::field::authorization, etpServerAuthorization);
m.insert(boost::beast::http::field::proxy_authorization, proxyAuthorization);
if (!proxyHost.empty() && !isTls()) {
m.insert(boost::beast::http::field::proxy_authorization, proxyAuthorization);
}
m.insert("etp-encoding", "binary");
for (const auto& mapEntry : additionalHandshakeHeaderFields_) {
m.insert(mapEntry.first, mapEntry.second);
Expand Down
1 change: 1 addition & 0 deletions src/etp/ClientSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ namespace ETP_NS
}

virtual void on_resolve(boost::system::error_code ec, tcp::resolver::results_type results) = 0;
virtual bool isTls() const = 0;

void on_handshake(boost::system::error_code ec)
{
Expand Down
2 changes: 2 additions & 0 deletions src/etp/PlainClientSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ namespace ETP_NS
// Called by the base class
FETPAPI_DLL_IMPORT_OR_EXPORT websocket::stream<tcp::socket>& ws() { return ws_; }

bool isTls() const final{ return false; }

void on_resolve(boost::system::error_code ec, tcp::resolver::results_type results)
{
if (ec) {
Expand Down
3 changes: 0 additions & 3 deletions src/etp/ssl/HttpsClientSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ namespace ETP_NS
if (!authorization.empty()) {
req_.set(http::field::authorization, authorization);
}
if (!proxyAuthorization.empty()) {
req_.set(http::field::proxy_authorization, proxyAuthorization);
}

if (!proxyHost.empty()) {
proxyHandshake.version(version);
Expand Down
2 changes: 2 additions & 0 deletions src/etp/ssl/SslClientSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ namespace ETP_NS
// Called by the base class
FETPAPI_DLL_IMPORT_OR_EXPORT websocket::stream<boost::beast::ssl_stream<tcp::socket>>& ws() { return ws_; }

bool isTls() const final { return true; }

void on_resolve(boost::system::error_code ec, tcp::resolver::results_type results)
{
if (ec) {
Expand Down

0 comments on commit e7de2a4

Please sign in to comment.