Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c3b34a0

Browse files
Fix certificate paths to use perl2host
Commit c113d8a moved the copying of certificates into a temporary path for the duration of the tests, instead of using the source tree. This broke the tests on msys as the absolute path wasn't adapted for the msys platform. Ensure to convert the path with perl2host before copying and passing in the connection string. While there also make certificate copying error handling uniform across all the test suites. Discussion: https://postgr.es/m/YacT3tm97xziSUFw@paquier.xyz
1 parent 81fca31 commit c3b34a0

File tree

3 files changed

+26
-17
lines changed

3 files changed

+26
-17
lines changed

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

+12-9
Original file line numberDiff line numberDiff line change
@@ -42,28 +42,31 @@
4242
# This changes to using keys stored in a temporary path for the rest of
4343
# the tests. To get the full path for inclusion in connection strings, the
4444
# %key hash can be interrogated.
45+
my $cert_tempdir = PostgreSQL::Test::Utils::tempdir();
4546
my %key;
4647
my @keys = (
4748
"client.key", "client-revoked.key",
4849
"client-der.key", "client-encrypted-pem.key",
4950
"client-encrypted-der.key", "client-dn.key");
5051
foreach my $keyfile (@keys)
5152
{
52-
copy("ssl/${keyfile}", "${PostgreSQL::Test::Utils::tmp_check}/${keyfile}")
53+
copy("ssl/$keyfile", "$cert_tempdir/$keyfile")
5354
or die
54-
"couldn't copy ssl/${keyfile} to ${PostgreSQL::Test::Utils::tmp_check}/${keyfile} for permissions change: $!";
55-
chmod 0600, "${PostgreSQL::Test::Utils::tmp_check}/${keyfile}"
56-
or die "failed to change permissions on ${PostgreSQL::Test::Utils::tmp_check}/${keyfile}: $!";
57-
58-
$key{$keyfile} = "${PostgreSQL::Test::Utils::tmp_check}/$keyfile";
55+
"couldn't copy ssl/$keyfile to $cert_tempdir/$keyfile for permissions change: $!";
56+
chmod 0600, "$cert_tempdir/$keyfile"
57+
or die "failed to change permissions on $cert_tempdir/$keyfile: $!";
58+
$key{$keyfile} = PostgreSQL::Test::Utils::perl2host("$cert_tempdir/$keyfile");
5959
}
6060

6161
# Also make a copy of that explicitly world-readable. We can't
6262
# necessarily rely on the file in the source tree having those
6363
# permissions.
64-
copy("ssl/client.key", "${PostgreSQL::Test::Utils::tmp_check}/client_wrongperms.key");
65-
chmod 0644, "${PostgreSQL::Test::Utils::tmp_check}/client_wrongperms.key";
66-
$key{'client_wrongperms.key'} = "${PostgreSQL::Test::Utils::tmp_check}/client_wrongperms.key";
64+
copy("ssl/client.key", "$cert_tempdir/client_wrongperms.key")
65+
or die
66+
"couldn't copy ssl/client_key to $cert_tempdir/client_wrongperms.key for permission change: $!";
67+
chmod 0644, "$cert_tempdir/client_wrongperms.key"
68+
or die "failed to change permissions on $cert_tempdir/client_wrongperms.key: $!";
69+
$key{'client_wrongperms.key'} = PostgreSQL::Test::Utils::perl2host("$cert_tempdir/client_wrongperms.key");
6770

6871
#### Set up the server.
6972

src/test/ssl/t/002_scram.pl

+7-3
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,13 @@
9595
# because channel binding is not performed. Note that ssl/client.key may
9696
# be used in a different test, so the name of this temporary client key
9797
# is chosen here to be unique.
98-
my $client_tmp_key = "${PostgreSQL::Test::Utils::tmp_check}/client_scram.key";
99-
copy("ssl/client.key", $client_tmp_key);
100-
chmod 0600, $client_tmp_key;
98+
my $cert_tempdir = PostgreSQL::Test::Utils::tempdir();
99+
my $client_tmp_key = PostgreSQL::Test::Utils::perl2host("$cert_tempdir/client_scram.key");
100+
copy("ssl/client.key", "$cert_tempdir/client_scram.key")
101+
or die
102+
"couldn't copy ssl/client_key to $cert_tempdir/client_scram.key for permission change: $!";
103+
chmod 0600, "$cert_tempdir/client_scram.key"
104+
or die "failed to change permissions on $cert_tempdir/client_scram.key: $!";
101105
$node->connect_fails(
102106
"sslcert=ssl/client.crt sslkey=$client_tmp_key sslrootcert=invalid hostaddr=$SERVERHOSTADDR dbname=certdb user=ssltestuser channel_binding=require",
103107
"Cert authentication and channel_binding=require",

src/test/ssl/t/003_sslinfo.pl

+7-5
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@
3737

3838
# The client's private key must not be world-readable, so take a copy
3939
# of the key stored in the code tree and update its permissions.
40-
my $client_tmp_key = "${PostgreSQL::Test::Utils::tmp_check}/client_ext.key";
41-
copy("ssl/client_ext.key", $client_tmp_key)
42-
or die "couldn't copy ssl/client_ext.key to $client_tmp_key for permissions change: $!";
43-
chmod 0600, $client_tmp_key
44-
or die "failed to change permissions on $client_tmp_key: $!";
40+
my $cert_tempdir = PostgreSQL::Test::Utils::tempdir();
41+
my $client_tmp_key = PostgreSQL::Test::Utils::perl2host("$cert_tempdir/client_ext.key");
42+
copy("ssl/client_ext.key", "$cert_tempdir/client_ext.key")
43+
or die
44+
"couldn't copy ssl/client_ext.key to $cert_tempdir/client_ext.key for permissions change: $!";
45+
chmod 0600, "$cert_tempdir/client_ext.key"
46+
or die "failed to change permissions on $cert_tempdir/client_ext.key: $!";
4547

4648
#### Set up the server.
4749

0 commit comments

Comments
 (0)