Skip to content

Commit 265c913

Browse files
peteremichaelpq
authored andcommitted
Define OPENSSL_API_COMPAT
This avoids deprecation warnings from newer OpenSSL versions (3.0.0 in particular). This has been originally applied as 4d3db13 for v14 and newer versions, but not on the older branches out of caution, and this commit closes the gap to remove all these deprecation warnings in all the branches still supported. OPENSSL_API_COMPAT's value is set based on the oldest version of OpenSSL supported on a branch: 1.0.1 for Postgres 13 and 0.9.8 for Postgres 11 and 12. Reviewed-by: Daniel Gustafsson Discussion: https://postgr.es/m/FEF81714-D479-4512-839B-C769D2605F8A@yesql.se Discussion: https://postgr.es/m/ZJJmOH+hIOSoesux@paquier.xyz Backpatch-through: 11
1 parent 4f8f0f8 commit 265c913

File tree

5 files changed

+25
-2
lines changed

5 files changed

+25
-2
lines changed

configure

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12405,7 +12405,11 @@ fi
1240512405
fi
1240612406

1240712407
if test "$with_openssl" = yes ; then
12408-
if test "$PORTNAME" != "win32"; then
12408+
# Minimum required OpenSSL version is 0.9.8
12409+
12410+
$as_echo "#define OPENSSL_API_COMPAT 0x00908000L" >>confdefs.h
12411+
12412+
if test "$PORTNAME" != "win32"; then
1240912413
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CRYPTO_new_ex_data in -lcrypto" >&5
1241012414
$as_echo_n "checking for CRYPTO_new_ex_data in -lcrypto... " >&6; }
1241112415
if ${ac_cv_lib_crypto_CRYPTO_new_ex_data+:} false; then :

configure.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,9 @@ fi
12741274

12751275
if test "$with_openssl" = yes ; then
12761276
dnl Order matters!
1277+
# Minimum required OpenSSL version is 0.9.8
1278+
AC_DEFINE(OPENSSL_API_COMPAT, [0x00908000L],
1279+
[Define to the OpenSSL API version in use. This avoids deprecation warnings from newer OpenSSL versions.])
12771280
if test "$PORTNAME" != "win32"; then
12781281
AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])])
12791282
AC_CHECK_LIB(ssl, SSL_new, [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])

src/include/pg_config.h.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,10 @@
808808
/* Define bytes to use libc memset(). */
809809
#undef MEMSET_LOOP_LIMIT
810810

811+
/* Define to the OpenSSL API version in use. This avoids deprecation warnings
812+
from newer OpenSSL versions. */
813+
#undef OPENSSL_API_COMPAT
814+
811815
/* Define to the address where bug reports for this package should be sent. */
812816
#undef PACKAGE_BUGREPORT
813817

src/include/pg_config.h.win32

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,10 @@
641641
/* Define bytes to use libc memset(). */
642642
#define MEMSET_LOOP_LIMIT 1024
643643

644+
/* Define to the OpenSSL API version in use. This avoids deprecation warnings
645+
from newer OpenSSL versions. */
646+
#define OPENSSL_API_COMPAT 0x00908000L
647+
644648
/* Define to the address where bug reports for this package should be sent. */
645649
#define PACKAGE_BUGREPORT "pgsql-bugs@lists.postgresql.org"
646650

src/tools/msvc/Solution.pm

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ sub GenerateFiles
147147
{
148148
my $self = shift;
149149
my $bits = $self->{platform} eq 'Win32' ? 32 : 64;
150+
my $openssl_api_compat;
151+
my $ac_define_openssl_api_compat_found = 0;
150152

151153
# Parse configure.in to get version numbers
152154
open(my $c, '<', "configure.in")
@@ -163,10 +165,15 @@ sub GenerateFiles
163165
$self->{numver} = sprintf("%d%04d", $1, $2 ? $2 : 0);
164166
$self->{majorver} = sprintf("%d", $1);
165167
}
168+
elsif (/\bAC_DEFINE\(OPENSSL_API_COMPAT, \[([0-9xL]+)\]/)
169+
{
170+
$ac_define_openssl_api_compat_found = 1;
171+
$openssl_api_compat = $1;
172+
}
166173
}
167174
close($c);
168175
confess "Unable to parse configure.in for all variables!"
169-
if ($self->{strver} eq '' || $self->{numver} eq '');
176+
if ($self->{strver} eq '' || $self->{numver} eq '' || $ac_define_openssl_api_compat_found == 0);
170177

171178
if (IsNewer("src/include/pg_config_os.h", "src/include/port/win32.h"))
172179
{
@@ -250,6 +257,7 @@ sub GenerateFiles
250257
if ($self->{options}->{openssl})
251258
{
252259
print $o "#define USE_OPENSSL 1\n";
260+
print $o "#define OPENSSL_API_COMPAT $openssl_api_compat\n";
253261

254262
my ($digit1, $digit2, $digit3) = $self->GetOpenSSLVersion();
255263

0 commit comments

Comments
 (0)