Skip to content

Commit

Permalink
Define OPENSSL_API_COMPAT
Browse files Browse the repository at this point in the history
This avoids deprecation warnings from newer OpenSSL versions (3.0.0 in
particular).

Discussion: https://www.postgresql.org/message-id/flat/FEF81714-D479-4512-839B-C769D2605F8A%40yesql.se
  • Loading branch information
petere committed Jul 19, 2020
1 parent 9b14280 commit 4d3db13
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
6 changes: 5 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -12174,7 +12174,11 @@ fi
fi

if test "$with_openssl" = yes ; then
if test "$PORTNAME" != "win32"; then
# Minimum required OpenSSL version is 1.0.1

$as_echo "#define OPENSSL_API_COMPAT 0x10001000L" >>confdefs.h

if test "$PORTNAME" != "win32"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CRYPTO_new_ex_data in -lcrypto" >&5
$as_echo_n "checking for CRYPTO_new_ex_data in -lcrypto... " >&6; }
if ${ac_cv_lib_crypto_CRYPTO_new_ex_data+:} false; then :
Expand Down
3 changes: 3 additions & 0 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,9 @@ fi

if test "$with_openssl" = yes ; then
dnl Order matters!
# Minimum required OpenSSL version is 1.0.1
AC_DEFINE(OPENSSL_API_COMPAT, [0x10001000L],
[Define to the OpenSSL API version in use. This avoids deprecation warnings from newer OpenSSL versions.])
if test "$PORTNAME" != "win32"; then
AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])])
AC_CHECK_LIB(ssl, SSL_new, [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
Expand Down
4 changes: 4 additions & 0 deletions src/include/pg_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,10 @@
/* Define bytes to use libc memset(). */
#undef MEMSET_LOOP_LIMIT

/* Define to the OpenSSL API version in use. This avoids deprecation warnings
from newer OpenSSL versions. */
#undef OPENSSL_API_COMPAT

/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT

Expand Down
10 changes: 9 additions & 1 deletion src/tools/msvc/Solution.pm
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ sub GenerateFiles
my $package_bugreport;
my $package_url;
my ($majorver, $minorver);
my $ac_define_openssl_api_compat_found = 0;
my $openssl_api_compat;

# Parse configure.in to get version numbers
open(my $c, '<', "configure.in")
Expand All @@ -176,10 +178,15 @@ sub GenerateFiles
$majorver = sprintf("%d", $1);
$minorver = sprintf("%d", $2 ? $2 : 0);
}
elsif (/\bAC_DEFINE\(OPENSSL_API_COMPAT, \[([0-9xL]+)\]/)
{
$ac_define_openssl_api_compat_found = 1;
$openssl_api_compat = $1;
}
}
close($c);
confess "Unable to parse configure.in for all variables!"
unless $ac_init_found;
unless $ac_init_found && $ac_define_openssl_api_compat_found;

if (IsNewer("src/include/pg_config_os.h", "src/include/port/win32.h"))
{
Expand Down Expand Up @@ -433,6 +440,7 @@ sub GenerateFiles
LOCALE_T_IN_XLOCALE => undef,
MAXIMUM_ALIGNOF => 8,
MEMSET_LOOP_LIMIT => 1024,
OPENSSL_API_COMPAT => $openssl_api_compat,
PACKAGE_BUGREPORT => qq{"$package_bugreport"},
PACKAGE_NAME => qq{"$package_name"},
PACKAGE_STRING => qq{"$package_name $package_version"},
Expand Down

0 comments on commit 4d3db13

Please sign in to comment.