Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,8 @@ Decoder::Result DecoderImpl::onDataInNegotiating(Buffer::Instance& data, bool fr

// This should be reply from the server indicating if it accepted
// request to use SSL. It is only one character long packet, where
// 'S' means use SSL, 'E' means do not use.
// 'S' means use SSL, 'N' means do not use.
// See details in https://www.postgresql.org/docs/current/protocol-flow.html#PROTOCOL-FLOW-SSL

// Indicate to the filter, the response and give the initial
// packet temporarily buffered to be sent upstream.
Expand All @@ -451,7 +452,7 @@ Decoder::Result DecoderImpl::onDataInNegotiating(Buffer::Instance& data, bool fr
if (c == 'S') {
upstreamSSL = true;
} else {
if (c != 'E') {
if (c != 'N') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. I do not remember why we used 'E'.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just for recording E is for ErrorResponse

state_ = State::OutOfSyncState;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ TEST_P(PostgresProxyUpstreamSSLTest, UpstreamSSLEnabled) {
ASSERT_THAT(decoder_->state(), DecoderImpl::State::NegotiatingUpstreamSSL);

// Simulate various responses from the upstream server.
// Only "S" and "E" are valid responses.
// Only "S" and "N" are valid responses.
data_.add(std::get<0>(GetParam()));

EXPECT_CALL(callbacks_, encryptUpstream(std::get<1>(GetParam()), testing::_));
Expand All @@ -665,7 +665,7 @@ INSTANTIATE_TEST_SUITE_P(BackendEncryptedMessagesTests, PostgresProxyUpstreamSSL
// Correct response from the server (encrypt).
std::make_tuple("S", true, DecoderImpl::State::InitState),
// Correct response from the server (do not encrypt).
std::make_tuple("E", false, DecoderImpl::State::InitState),
std::make_tuple("N", false, DecoderImpl::State::InitState),
// Incorrect response from the server. Move to out-of-sync state.
std::make_tuple("W", false, DecoderImpl::State::OutOfSyncState),
std::make_tuple("WRONG", false, DecoderImpl::State::OutOfSyncState)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,8 @@ TEST_P(UpstreamSSLRequirePostgresIntegrationTest, ServerDeniesSSLTest) {
ASSERT_EQ(80877103, upstream_data.peekBEInt<uint32_t>(4));
upstream_data.drain(upstream_data.length());

// Reply to Envoy with 'E' (SSL not allowed).
upstream_data.add("E");
// Reply to Envoy with 'N' (SSL not allowed).
upstream_data.add("N");
ASSERT_TRUE(fake_upstream_connection_->write(upstream_data.toString()));
config_factory_.proceed_sync_.Notify();

Expand Down