Skip to content

Commit f03bd57

Browse files
committed
Use existing SSL certs in LDAP tests instead of generating them
The SSL test suite has a bunch of pre-existing certificates, so it's better simply to use what we already have than generate new certificates each time the LDAP tests are run. Discussion: https://postgr.es/m/bc305c7a-f390-44f2-2e82-9bcaec6108da@dunslane.net
1 parent 8284cf5 commit f03bd57

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

src/test/ldap/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ top_builddir = ../../..
1414
include $(top_builddir)/src/Makefile.global
1515

1616
export with_ldap
17-
export OPENSSL
1817

1918
check:
2019
$(prove_check)

src/test/ldap/meson.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ tests += {
1010
],
1111
'env': {
1212
'with_ldap': ldap.found() ? 'yes' : 'no',
13-
'OPENSSL': openssl.path(),
1413
},
1514
},
1615
}

src/test/ldap/t/001_auth.pl

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
use strict;
55
use warnings;
6+
use File::Copy;
67
use PostgreSQL::Test::Utils;
78
use PostgreSQL::Test::Cluster;
89
use Test::More;
@@ -113,17 +114,13 @@
113114
mkdir $ldap_datadir or die;
114115
mkdir $slapd_certs or die;
115116

116-
my $openssl = $ENV{OPENSSL};
117-
118-
system_or_bail $openssl, "req", "-new", "-nodes", "-keyout",
119-
"$slapd_certs/ca.key", "-x509", "-out", "$slapd_certs/ca.crt", "-subj",
120-
"/CN=CA";
121-
system_or_bail $openssl, "req", "-new", "-nodes", "-keyout",
122-
"$slapd_certs/server.key", "-out", "$slapd_certs/server.csr", "-subj",
123-
"/CN=server";
124-
system_or_bail $openssl, "x509", "-req", "-in", "$slapd_certs/server.csr",
125-
"-CA", "$slapd_certs/ca.crt", "-CAkey", "$slapd_certs/ca.key",
126-
"-CAcreateserial", "-out", "$slapd_certs/server.crt";
117+
# use existing certs from nearby SSL test suite
118+
copy "../ssl/ssl/server_ca.crt", "$slapd_certs/ca.crt"
119+
|| die "copying ca.crt: $!";
120+
copy "../ssl/ssl/server-cn-only.crt", "$slapd_certs/server.crt"
121+
|| die "copying server.crt: $!";;
122+
copy "../ssl/ssl/server-cn-only.key", "$slapd_certs/server.key"
123+
|| die "copying server.key: $!";;
127124

128125
system_or_bail $slapd, '-f', $slapd_conf, '-h', "$ldap_url $ldaps_url";
129126

src/test/ssl/README

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ recreate them if you need to make changes. "make sslfiles-clean" is required
9393
in order to recreate the full set of keypairs and certificates. To rebuild
9494
separate files, touch (or remove) the files in question and run "make sslfiles".
9595

96+
Note
97+
====
98+
99+
These certificates are also used in other tests, e.g. the LDAP tests.
100+
96101
TODO
97102
====
98103

0 commit comments

Comments
 (0)