pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Tom Lane <tgl@sss.pgh.pa.us>
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 14:25:48 +0900
Message-ID: <20190926052548.GD2115@paquier.xyz> (raw)
In-Reply-To: <22006.1569343397@sss.pgh.pa.us>
References: <20190924101859.09383b4f@fafnir.local.vm>
	<20190924094917.GB1982@paquier.xyz>
	<20190924130731.2270332e@fafnir.local.vm>
	<22006.1569343397@sss.pgh.pa.us>

On Tue, Sep 24, 2019 at 12:43:17PM -0400, Tom Lane wrote:
> One thing I'm wondering is if it's safe to assume that TLS_MAX_VERSION
> will be defined whenever these other symbols are.  Looking in an
> 0.9.8x install tree, that doesn't seem to define any of them; while
> in 1.0.1e I see

Yeah, I could personally live with the argument of simplicity and just
say that trying to compile v12 with any version older than 0.9.8zc or
any version that does not have those symbols just does not work, and
that one needs to use the top of the released versions.

> ./tls1.h:#define TLS1_1_VERSION                 0x0302
> ./tls1.h:#define TLS1_2_VERSION                 0x0303
> ./tls1.h:#define TLS_MAX_VERSION                        TLS1_2_VERSION
>
> So the patch seems okay for these two versions, but I have no data about
> intermediate OpenSSL versions.

More precisely, all those fields have been added by this upstream
commit, so the fields are present since 0.9.8zc:
commit: c6a876473cbff0fd323c8abcaace98ee2d21863d
author: Bodo Moeller <bodo@openssl.org>
date: Wed, 15 Oct 2014 04:18:29 +0200
Support TLS_FALLBACK_SCSV.

> BTW, the spacing in this patch seems rather random.

Indeed.

Now that I think about it, another method would be to rely on the fact
that a given version of OpenSSL does not support TLS 1.1 and 1.2.  So
we could also just add checks based on OPENSSL_VERSION_NUMBER and be
done with it.  And actually, looking at their tree TLS 1.1 and 2.2 are
not supported in 1.0.0 either.  1.0.1, 1.0.2, 1.1.0 and HEAD do
support them, but not TLS 1.3.

I would still prefer relying on TLS_MAX_VERSION though, as that's more
portable for future decisions, like the introduction of TLS1_3_VERSION
for which we have already some logic in be-secure-openssl.c.  And
updating this stuff would very likely get forgotten once OpenSSL adds
support for TLS 1.3...

There is another issue in the patch:
-#ifdef TLS1_3_VERSION
+#if defined(TLS1_3_VERSION)  &&  TLS1_2_VERSION <= TLS_MAX_VERSION
The second part of the if needs to use TLS1_3_VERSION.

I would also add more brackets around the extra conditions for
readability.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (20+ messages)  latest in thread

Message-ID: <20190926052548.GD2115@paquier.xyz>
Permalink:  ../20190926052548.GD2115@paquier.xyz/
Also on:    postgresql.org/message-id/20190926052548.GD2115@paquier.xyz

 · 

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: michael@paquier.xyz, tgl@sss.pgh.pa.us, vitus@wagner.pp.ru
  Subject: Re: PostgreSQL12 and older versions of OpenSSL
  In-Reply-To: <20190926052548.GD2115@paquier.xyz>
  References: <20190924101859.09383b4f@fafnir.local.vm> <20190924094917.GB1982@paquier.xyz> <20190924130731.2270332e@fafnir.local.vm> <22006.1569343397@sss.pgh.pa.us> <20190926052548.GD2115@paquier.xyz>

* 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