Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0aaf699

Browse files
committed
Centralize ssl tests' check for whether we're using LibreSSL.
Right now there's only one caller, so that this is merely an exercise in shoving code from one module to another, but there will shortly be another one. It seems better to avoid having two copies of this highly-subject-to-change test. Back-patch to v15, where we first introduced some tests that don't work with LibreSSL. Reported-by: Thomas Munro <[email protected]> Author: Tom Lane <[email protected]> Reviewed-by: Daniel Gustafsson <[email protected]> Discussion: https://postgr.es/m/CA+hUKG+fLqyweHqFSBcErueUVT0vDuSNWui-ySz3+d_APmq7dw@mail.gmail.com Backpatch-through: 15
1 parent bc35ade commit 0aaf699

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

src/test/ssl/t/001_ssltests.pl

+2-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ sub switch_server_cert
3535
$ssl_server->switch_server_cert(@_);
3636
}
3737

38-
# Determine whether this build uses OpenSSL or LibreSSL. As a heuristic, the
39-
# HAVE_SSL_CTX_SET_CERT_CB macro isn't defined for LibreSSL.
40-
my $libressl = not check_pg_config("#define HAVE_SSL_CTX_SET_CERT_CB 1");
38+
# Determine whether this build uses OpenSSL or LibreSSL.
39+
my $libressl = $ssl_server->is_libressl;
4140

4241
#### Some configuration
4342

src/test/ssl/t/SSL/Backend/OpenSSL.pm

+18
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ package SSL::Backend::OpenSSL;
2626

2727
use strict;
2828
use warnings FATAL => 'all';
29+
use PostgreSQL::Test::Utils;
2930
use File::Basename;
3031
use File::Copy;
3132

@@ -205,6 +206,23 @@ sub get_library
205206
return $self->{_library};
206207
}
207208

209+
=pod
210+
211+
=item $backend->library_is_libressl()
212+
213+
Detect whether the SSL library is LibreSSL.
214+
215+
=cut
216+
217+
sub library_is_libressl
218+
{
219+
my ($self) = @_;
220+
221+
# The HAVE_SSL_CTX_SET_CERT_CB macro isn't defined for LibreSSL.
222+
# We may eventually need a less-bogus heuristic.
223+
return not check_pg_config("#define HAVE_SSL_CTX_SET_CERT_CB 1");
224+
}
225+
208226
# Internal method for copying a set of files, taking into account wildcards
209227
sub _copy_files
210228
{

src/test/ssl/t/SSL/Server.pm

+17
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,23 @@ sub ssl_library
244244

245245
=pod
246246
247+
=item $server->is_libressl()
248+
249+
Detect whether the currently used SSL backend is LibreSSL.
250+
(Ideally we'd not need this hack, but presently we do.)
251+
252+
=cut
253+
254+
sub is_libressl
255+
{
256+
my $self = shift;
257+
my $backend = $self->{backend};
258+
259+
return $backend->library_is_libressl();
260+
}
261+
262+
=pod
263+
247264
=item switch_server_cert(params)
248265
249266
Change the configuration to use the given set of certificate, key, ca and

0 commit comments

Comments
 (0)