Skip to content

Commit 643a241

Browse files
postgres: support require downstream ssl (#39431)
<!-- !!!ATTENTION!!! If you are fixing *any* crash or *any* potential security issue, *do not* open a pull request in this repo. Please report the issue via emailing [email protected] where the issue will be triaged appropriately. Thank you in advance for helping to keep Envoy secure. !!!ATTENTION!!! For an explanation of how to fill out the fields, please see the relevant section in [PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md) --> Commit Message: Support require downstream ssl in postgres filter. Once this value is set to true and client doesn't send ssl negotiation message, postgres will send back an error response and close connection. The behavior won't change for current users, because the default is set to false that downstream ssl is not required. fix: envoyproxy/envoy#31049 Additional Description: Risk Level: Low Testing: unit test and tested locally Docs Changes: changelogs/current.yaml Release Notes: Platform Specific Features: [Optional Runtime guard:] [Optional Fixes #Issue] [Optional Fixes commit #PR or SHA] [Optional Deprecated:] [Optional [API Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):] --------- Signed-off-by: Yuanguo Lang <[email protected]> Mirrored from https://github.com/envoyproxy/envoy @ 412bfa4ea4e4216eef9e82dcd2c49f5bf7765a5a
1 parent f58e31f commit 643a241

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

contrib/envoy/extensions/filters/network/postgres_proxy/v3alpha/BUILD

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@ load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package")
55
licenses(["notice"]) # Apache 2
66

77
api_proto_package(
8-
deps = ["@com_github_cncf_xds//udpa/annotations:pkg"],
8+
deps = [
9+
"//envoy/annotations:pkg",
10+
"@com_github_cncf_xds//udpa/annotations:pkg",
11+
],
912
)

contrib/envoy/extensions/filters/network/postgres_proxy/v3alpha/postgres_proxy.proto

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package envoy.extensions.filters.network.postgres_proxy.v3alpha;
44

55
import "google/protobuf/wrappers.proto";
66

7+
import "envoy/annotations/deprecation.proto";
78
import "udpa/annotations/status.proto";
89
import "validate/validate.proto";
910

@@ -19,15 +20,26 @@ option (udpa.annotations.file_status).package_version_status = ACTIVE;
1920
// <config_network_filters_postgres_proxy>`.
2021
// [#extension: envoy.filters.network.postgres_proxy]
2122

23+
// [#next-free-field: 6]
2224
message PostgresProxy {
23-
// Upstream SSL operational modes.
25+
// Downstream and Upstream SSL operational modes.
2426
enum SSLMode {
25-
// Do not encrypt upstream connection to the server.
27+
// If used in downstream ssl, do not terminate SSL session initiated by a client.
28+
// The Postgres proxy filter will pass all encrypted and unencrypted packets to the upstream server.
29+
// If used in upstream ssl, do not encrypt upstream connection to the server.
2630
DISABLE = 0;
2731

28-
// Establish upstream SSL connection to the server. If the server does not
32+
// If used in downstream ssl, the Postgres proxy filter will terminate SSL
33+
// session and close downstream connections that refuse to upgrade to SSL.
34+
// If used in upstream SSL, establish upstream SSL connection to the server. If the server does not
2935
// accept the request for SSL connection, the session is terminated.
3036
REQUIRE = 1;
37+
38+
// If used in downstream SSL, the Postgres proxy filter will accept downstream
39+
// client's encryption settings. If the client wants to use clear-text,
40+
// Envoy will not enforce SSL encryption.
41+
// If the client wants to use encryption, Envoy will terminate SSL.
42+
ALLOW = 2;
3143
}
3244

3345
// The human readable prefix to use when emitting :ref:`statistics
@@ -48,7 +60,10 @@ message PostgresProxy {
4860
// If the filter does not manage to terminate the SSL session, it will close the connection from the client.
4961
// Refer to official documentation for details
5062
// `SSL Session Encryption Message Flow <https://www.postgresql.org/docs/current/protocol-flow.html#id-1.10.5.7.11>`_.
51-
bool terminate_ssl = 3;
63+
// This field is deprecated.
64+
// Please use :ref:`downstream_ssl <envoy_v3_api_field_extensions.filters.network.postgres_proxy.v3alpha.PostgresProxy.downstream_ssl>`.
65+
bool terminate_ssl = 3
66+
[deprecated = true, (envoy.annotations.deprecated_at_minor_version) = "3.0"];
5267

5368
// Controls whether to establish upstream SSL connection to the server.
5469
// Envoy will try to establish upstream SSL connection to the server only when
@@ -57,6 +72,12 @@ message PostgresProxy {
5772
// SSL connection to Envoy and Postgres filter is configured to terminate SSL.
5873
// In order for upstream encryption to work, the corresponding cluster must be configured to use
5974
// :ref:`starttls transport socket <envoy_v3_api_msg_extensions.transport_sockets.starttls.v3.UpstreamStartTlsConfig>`.
60-
// Defaults to ``SSL_DISABLE``.
75+
// Defaults to ``DISABLE``.
6176
SSLMode upstream_ssl = 4;
77+
78+
// Controls whether to close downstream connections that refuse to upgrade to SSL.
79+
// If enabled, the filter chain must use
80+
// :ref:`starttls transport socket <envoy_v3_api_msg_extensions.transport_sockets.starttls.v3.UpstreamStartTlsConfig>`.
81+
// Defaults to ``DISABLE``.
82+
SSLMode downstream_ssl = 5;
6283
}

0 commit comments

Comments
 (0)