mirror of
https://github.com/postgres/postgres.git
synced 2025-10-21 02:52:47 +03:00
Avoid warnings in tests when openssl binary isn't available
The SSL tests for pg_stat_ssl tries to exactly match the serial
from the certificate by extracting it with the openssl binary.
If that fails due to the binary not being available, a fallback
match is used, but the attempt to execute a missing binary adds
a warning to the output which can confuse readers for a failure
in the test. Fix by only attempting if the openssl binary was
found by autoconf/meson.
Backpatch down to v16 where commit c8e4030d1b
made the test
use the OPENSSL variable from autoconf/meson instead of a hard-
coded value.
Author: Daniel Gustafsson <daniel@yesql.se>
Reported-by: Christoph Berg <myon@debian.org>
Discussion: https://postgr.es/m/aNPSp1-RIAs3skZm@msg.df7cb.de
Backpatch-through: 16
This commit is contained in:
@@ -748,7 +748,13 @@ TODO:
|
|||||||
|
|
||||||
# pg_stat_ssl
|
# pg_stat_ssl
|
||||||
|
|
||||||
my $serialno = `$ENV{OPENSSL} x509 -serial -noout -in ssl/client.crt`;
|
# If the openssl program isn't available, or fails to run, fall back to a
|
||||||
|
# generic integer match rather than skipping the test.
|
||||||
|
my $serialno = '\d+';
|
||||||
|
|
||||||
|
if ($ENV{OPENSSL} ne '')
|
||||||
|
{
|
||||||
|
$serialno = `$ENV{OPENSSL} x509 -serial -noout -in ssl/client.crt`;
|
||||||
if ($? == 0)
|
if ($? == 0)
|
||||||
{
|
{
|
||||||
# OpenSSL prints serial numbers in hexadecimal and converting the serial
|
# OpenSSL prints serial numbers in hexadecimal and converting the serial
|
||||||
@@ -763,18 +769,8 @@ if ($? == 0)
|
|||||||
$serialno =~ s/\s+//g;
|
$serialno =~ s/\s+//g;
|
||||||
$serialno = hex($serialno);
|
$serialno = hex($serialno);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$serialno = '\d+';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
# OpenSSL isn't functioning on the user's PATH. This probably isn't worth
|
|
||||||
# skipping the test over, so just fall back to a generic integer match.
|
|
||||||
warn "couldn't run \"$ENV{OPENSSL} x509\" to get client cert serialno";
|
|
||||||
$serialno = '\d+';
|
|
||||||
}
|
|
||||||
|
|
||||||
command_like(
|
command_like(
|
||||||
[
|
[
|
||||||
|
Reference in New Issue
Block a user