Skip to content

Commit e7de2a4

Browse files
Avoid sending proxy authorization when ssl tunnel is done
1 parent 7bbf5e4 commit e7de2a4

5 files changed

Lines changed: 11 additions & 5 deletions

File tree

src/etp/AbstractClientSessionCRTP.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ namespace ETP_NS
4444
{
4545
m.insert(boost::beast::http::field::sec_websocket_protocol, "etp12.energistics.org");
4646
m.insert(boost::beast::http::field::authorization, etpServerAuthorization);
47-
m.insert(boost::beast::http::field::proxy_authorization, proxyAuthorization);
47+
if (!proxyHost.empty() && !isTls()) {
48+
m.insert(boost::beast::http::field::proxy_authorization, proxyAuthorization);
49+
}
4850
m.insert("etp-encoding", "binary");
4951
for (const auto& mapEntry : additionalHandshakeHeaderFields_) {
5052
m.insert(mapEntry.first, mapEntry.second);
@@ -60,7 +62,9 @@ namespace ETP_NS
6062
{
6163
m.insert(boost::beast::http::field::sec_websocket_protocol, "etp12.energistics.org");
6264
m.insert(boost::beast::http::field::authorization, etpServerAuthorization);
63-
m.insert(boost::beast::http::field::proxy_authorization, proxyAuthorization);
65+
if (!proxyHost.empty() && !isTls()) {
66+
m.insert(boost::beast::http::field::proxy_authorization, proxyAuthorization);
67+
}
6468
m.insert("etp-encoding", "binary");
6569
for (const auto& mapEntry : additionalHandshakeHeaderFields_) {
6670
m.insert(mapEntry.first, mapEntry.second);

src/etp/ClientSession.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ namespace ETP_NS
7070
}
7171

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

7475
void on_handshake(boost::system::error_code ec)
7576
{

src/etp/PlainClientSession.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ namespace ETP_NS
3737
// Called by the base class
3838
FETPAPI_DLL_IMPORT_OR_EXPORT websocket::stream<tcp::socket>& ws() { return ws_; }
3939

40+
bool isTls() const final{ return false; }
41+
4042
void on_resolve(boost::system::error_code ec, tcp::resolver::results_type results)
4143
{
4244
if (ec) {

src/etp/ssl/HttpsClientSession.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ namespace ETP_NS
9292
if (!authorization.empty()) {
9393
req_.set(http::field::authorization, authorization);
9494
}
95-
if (!proxyAuthorization.empty()) {
96-
req_.set(http::field::proxy_authorization, proxyAuthorization);
97-
}
9895

9996
if (!proxyHost.empty()) {
10097
proxyHandshake.version(version);

src/etp/ssl/SslClientSession.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ namespace ETP_NS
5858
// Called by the base class
5959
FETPAPI_DLL_IMPORT_OR_EXPORT websocket::stream<boost::beast::ssl_stream<tcp::socket>>& ws() { return ws_; }
6060

61+
bool isTls() const final { return true; }
62+
6163
void on_resolve(boost::system::error_code ec, tcp::resolver::results_type results)
6264
{
6365
if (ec) {

0 commit comments

Comments
 (0)