Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iCf6K-0005b1-4W for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Sep 2019 07:19:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iCf6I-0008Lc-8o for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Sep 2019 07:19:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iCf6I-0008LI-0Y for pgsql-hackers@lists.postgresql.org; Tue, 24 Sep 2019 07:19:06 +0000 Received: from mx.wagner.pp.ru ([78.46.190.96]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iCf6E-0004tg-No for pgsql-hackers@lists.postgresql.org; Tue, 24 Sep 2019 07:19:05 +0000 Received: from fafnir.local.vm (unknown [93.174.131.141]) by mx.wagner.pp.ru (Postfix) with ESMTPSA id 9C618E0198 for ; Tue, 24 Sep 2019 10:19:00 +0300 (MSK) Date: Tue, 24 Sep 2019 10:18:59 +0300 From: Victor Wagner To: pgsql-hackers@lists.postgresql.org Subject: PostgreSQL12 and older versions of OpenSSL Message-ID: <20190924101859.09383b4f@fafnir.local.vm> X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Dear hackers, PostgreSQL 12 documentation states, that minimum required version of OpenSSL is 0.9.8. However, I was unable to =D1=81ompile current PGPRO_12_STABLE with OpenSSL 0.9.8j (from SLES 11sp4). -fno-strict-aliasing -fwrapv -g -O2 -I../../../src/include -D_GNU_SOURCE -= I/usr/include/libxml2 -c -o be-secure-openssl.o be-secure-openssl.c be-secure-openssl.c: In function =E2=80=98SSL_CTX_set_min_proto_version=E2= =80=99: be-secure-openssl.c:1340: error: =E2=80=98SSL_OP_NO_TLSv1_1=E2=80=99 undecl= ared (first use in this function) be-secure-openssl.c:1340: error: (Each undeclared identifier is reported on= ly once be-secure-openssl.c:1340: error: for each function it appears in.) be-secure-openssl.c:1344: error: =E2=80=98SSL_OP_NO_TLSv1_2=E2=80=99 undecl= ared (first use in this function) be-secure-openssl.c: In function =E2=80=98SSL_CTX_set_max_proto_version=E2= =80=99: be-secure-openssl.c:1361: error: =E2=80=98SSL_OP_NO_TLSv1_1=E2=80=99 undecl= ared (first use in this function) be-secure-openssl.c:1365: error: =E2=80=98SSL_OP_NO_TLSv1_2=E2=80=99 undecl= ared (first use in this function) make: *** [be-secure-openssl.o] Error 1 Problem is that some code in src/backend/libpq/be-secure-openssl.c assumes that if preprocessor symbols TLS1_1_VERSION and TLS1_2_VERSION are defined in the openssl headers, corresponding versions of TLS are supported by the library. It is not so. Here is exempt from tls1.h header file from the openssl 0.9.8j #define TLS1_VERSION 0x0301 #define TLS1_1_VERSION 0x0302 #define TLS1_2_VERSION 0x0303 /* TLS 1.1 and 1.2 are not supported by this version of OpenSSL, so * TLS_MAX_VERSION indicates TLS 1.0 regardless of the above * definitions. (s23_clnt.c and s23_srvr.c have an OPENSSL_assert() * check that would catch the error if TLS_MAX_VERSION was too low.) */ #define TLS_MAX_VERSION TLS1_VERSION Replacing all=20 #ifdef TLS1_1_VERSION with #if defined(TLS1_1_VERSION) && TLS1_1_VERSION <=3D TLS_MAX_VERSION and analogue for TLS1_2_VERSION fixes the problem. Really, problem is that symbol SSL_OP_NO_TLSv1_1 (and 1_2 accordingly) might be undefined even if TLS1_1_VERSION defined.=20 Replacing=20 #ifdef TLS1_1_VERSION with=20 #ifdef SSL_OP_NO_TLSv1_1=20 seems to be correct solution for two of three #ifdef TLS1_1_VERSION statements in be-secure-openssl.c, because this symbol is used inside #ifdef block. But there is third (first from start of file) one. ... case PG_TLS1_1_VERSION: #ifdef TLS1_1_VERSION return TLS1_1_VERSION; #else break; #endif ... (line 1290). In this case check for TLS1_1_VERSION <=3D TLS_MAX_VERSION seems to be more self-explanatory, than check for somewhat unrelated=20 symbol SSL_OP_NO_TLSv1_1 =20 --=20