pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Victor Wagner <vitus@wagner.pp.ru>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: PostgreSQL12 and older versions of OpenSSL
Date: Thu, 26 Sep 2019 18:24:22 +0200
Message-ID: <000788f2-631c-2731-4ce0-d2ea07c4c32e@2ndquadrant.com> (raw)
In-Reply-To: <58f51c56-1764-3d05-d07a-ee5666169f72@2ndquadrant.com>
References: <20190924101859.09383b4f@fafnir.local.vm>
	<bdb92317-6138-f40c-070d-a357e475a07f@2ndquadrant.com>
	<20190926045314.GC2115@paquier.xyz>
	<58f51c56-1764-3d05-d07a-ee5666169f72@2ndquadrant.com>

Here is my proposed patch, currently completely untested.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachments:

0001-Fix-compilation-with-older-OpenSSL-versions.patch (text/plain, 2.2K) download From 35324dbe908a779c9d84b438cb54328cfd74e403 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <peter@eisentraut.org> Date: Thu, 26 Sep 2019 18:22:56 +0200 Subject: [PATCH] Fix compilation with older OpenSSL versions TODO explanation here --- src/backend/libpq/be-secure-openssl.c | 35 +++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/backend/libpq/be-secure-openssl.c b/src/backend/libpq/be-secure-openssl.c index c97c811e63..020f7c7f62 100644 --- a/src/backend/libpq/be-secure-openssl.c +++ b/src/backend/libpq/be-secure-openssl.c @@ -198,7 +198,8 @@ be_tls_init(bool isServerStart) if (ssl_ver == -1) goto error; - SSL_CTX_set_min_proto_version(context, ssl_ver); + if (!SSL_CTX_set_min_proto_version(context, ssl_ver)) + goto error; } if (ssl_max_protocol_version) @@ -209,7 +210,8 @@ be_tls_init(bool isServerStart) if (ssl_ver == -1) goto error; - SSL_CTX_set_max_proto_version(context, ssl_ver); + if (!SSL_CTX_set_max_proto_version(context, ssl_ver)) + goto error; } /* disallow SSL session tickets */ @@ -1335,13 +1337,30 @@ SSL_CTX_set_min_proto_version(SSL_CTX *ctx, int version) if (version > TLS1_VERSION) ssl_options |= SSL_OP_NO_TLSv1; + /* + * Some OpenSSL versions define TLS*_VERSION macros but not the + * corresponding SSL_OP_NO_* macro, so in those cases we have to return + * unsuccessfully here. + */ #ifdef TLS1_1_VERSION if (version > TLS1_1_VERSION) + { +#ifdef SSL_OP_NO_TLSv1_1 ssl_options |= SSL_OP_NO_TLSv1_1; +#else + return 0; +#endif + } #endif #ifdef TLS1_2_VERSION if (version > TLS1_2_VERSION) + { +#ifdef SSL_OP_NO_TLSv1_2 ssl_options |= SSL_OP_NO_TLSv1_2; +#else + return 0; +#endif + } #endif SSL_CTX_set_options(ctx, ssl_options); @@ -1358,11 +1377,23 @@ SSL_CTX_set_max_proto_version(SSL_CTX *ctx, int version) #ifdef TLS1_1_VERSION if (version < TLS1_1_VERSION) + { +#ifdef SSL_OP_NO_TLSv1_1 ssl_options |= SSL_OP_NO_TLSv1_1; +#else + return 0; +#endif + } #endif #ifdef TLS1_2_VERSION if (version < TLS1_2_VERSION) + { +#ifdef SSL_OP_NO_TLSv1_2 ssl_options |= SSL_OP_NO_TLSv1_2; +#else + return 0; +#endif + } #endif SSL_CTX_set_options(ctx, ssl_options); -- 2.23.0

view thread (20+ messages)  latest in thread

Message-ID: <000788f2-631c-2731-4ce0-d2ea07c4c32e@2ndquadrant.com>
Permalink:  ../000788f2-631c-2731-4ce0-d2ea07c4c32e@2ndquadrant.com/
Also on:    postgresql.org/message-id/000788f2-631c-2731-4ce0-d2ea07c4c32e@2ndquadrant.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: peter.eisentraut@2ndquadrant.com, michael@paquier.xyz, vitus@wagner.pp.ru
  Subject: Re: PostgreSQL12 and older versions of OpenSSL
  In-Reply-To: <000788f2-631c-2731-4ce0-d2ea07c4c32e@2ndquadrant.com>
  References: <20190924101859.09383b4f@fafnir.local.vm> <bdb92317-6138-f40c-070d-a357e475a07f@2ndquadrant.com> <20190926045314.GC2115@paquier.xyz> <58f51c56-1764-3d05-d07a-ee5666169f72@2ndquadrant.com> <000788f2-631c-2731-4ce0-d2ea07c4c32e@2ndquadrant.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox