diff options
author | Tom Lane | 2020-06-27 16:47:58 +0000 |
---|---|---|
committer | Tom Lane | 2020-06-27 16:47:58 +0000 |
commit | b63dd3d88f479947ef7fb7cbf5db27de66ae0654 (patch) | |
tree | d9278731eeb77c93b702190977072e4f521c14ea /src/include | |
parent | 6e682f61a5bdb08164a805419144318db6b7229f (diff) |
Add hints about protocol-version-related SSL connection failures.
OpenSSL's native reports about problems related to protocol version
restrictions are pretty opaque and inconsistent. When we get an
SSL error that is plausibly due to this, emit a hint message that
includes the range of SSL protocol versions we (think we) are
allowing. This should at least get the user thinking in the right
direction to resolve the problem, even if the hint isn't totally
accurate, which it might not be for assorted reasons.
Back-patch to v13 where we increased the default minimum protocol
version, thereby increasing the risk of this class of failure.
Patch by me, reviewed by Daniel Gustafsson
Discussion: https://postgr.es/m/a9408304-4381-a5af-d259-e55d349ae4ce@2ndquadrant.com
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/common/openssl.h | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/include/common/openssl.h b/src/include/common/openssl.h index 47fa1299945..9d1c681d9f8 100644 --- a/src/include/common/openssl.h +++ b/src/include/common/openssl.h @@ -17,12 +17,33 @@ #ifdef USE_OPENSSL #include <openssl/ssl.h> +/* + * OpenSSL doesn't provide any very nice way to identify the min/max + * protocol versions the library supports, so we fake it as best we can. + * Note in particular that this doesn't account for restrictions that + * might be specified in the installation's openssl.cnf. + * + * We disable SSLv3 and older in library setup, so TLSv1 is the oldest + * protocol version of interest. + */ +#define MIN_OPENSSL_TLS_VERSION "TLSv1" + +#if defined(TLS1_3_VERSION) +#define MAX_OPENSSL_TLS_VERSION "TLSv1.3" +#elif defined(TLS1_2_VERSION) +#define MAX_OPENSSL_TLS_VERSION "TLSv1.2" +#elif defined(TLS1_1_VERSION) +#define MAX_OPENSSL_TLS_VERSION "TLSv1.1" +#else +#define MAX_OPENSSL_TLS_VERSION "TLSv1" +#endif + /* src/common/protocol_openssl.c */ #ifndef SSL_CTX_set_min_proto_version extern int SSL_CTX_set_min_proto_version(SSL_CTX *ctx, int version); extern int SSL_CTX_set_max_proto_version(SSL_CTX *ctx, int version); #endif -#endif +#endif /* USE_OPENSSL */ #endif /* COMMON_OPENSSL_H */ |