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
This commit is contained in:
Andrew Dunstan 2022-12-19 05:58:08 -05:00
parent 8284cf5f74
commit f03bd5717e
4 changed files with 13 additions and 13 deletions

View File

@ -14,7 +14,6 @@ top_builddir = ../../..
include $(top_builddir)/src/Makefile.global include $(top_builddir)/src/Makefile.global
export with_ldap export with_ldap
export OPENSSL
check: check:
$(prove_check) $(prove_check)

View File

@ -10,7 +10,6 @@ tests += {
], ],
'env': { 'env': {
'with_ldap': ldap.found() ? 'yes' : 'no', 'with_ldap': ldap.found() ? 'yes' : 'no',
'OPENSSL': openssl.path(),
}, },
}, },
} }

View File

@ -3,6 +3,7 @@
use strict; use strict;
use warnings; use warnings;
use File::Copy;
use PostgreSQL::Test::Utils; use PostgreSQL::Test::Utils;
use PostgreSQL::Test::Cluster; use PostgreSQL::Test::Cluster;
use Test::More; use Test::More;
@ -113,17 +114,13 @@ append_to_file(
mkdir $ldap_datadir or die; mkdir $ldap_datadir or die;
mkdir $slapd_certs or die; mkdir $slapd_certs or die;
my $openssl = $ENV{OPENSSL}; # use existing certs from nearby SSL test suite
copy "../ssl/ssl/server_ca.crt", "$slapd_certs/ca.crt"
system_or_bail $openssl, "req", "-new", "-nodes", "-keyout", || die "copying ca.crt: $!";
"$slapd_certs/ca.key", "-x509", "-out", "$slapd_certs/ca.crt", "-subj", copy "../ssl/ssl/server-cn-only.crt", "$slapd_certs/server.crt"
"/CN=CA"; || die "copying server.crt: $!";;
system_or_bail $openssl, "req", "-new", "-nodes", "-keyout", copy "../ssl/ssl/server-cn-only.key", "$slapd_certs/server.key"
"$slapd_certs/server.key", "-out", "$slapd_certs/server.csr", "-subj", || die "copying server.key: $!";;
"/CN=server";
system_or_bail $openssl, "x509", "-req", "-in", "$slapd_certs/server.csr",
"-CA", "$slapd_certs/ca.crt", "-CAkey", "$slapd_certs/ca.key",
"-CAcreateserial", "-out", "$slapd_certs/server.crt";
system_or_bail $slapd, '-f', $slapd_conf, '-h', "$ldap_url $ldaps_url"; system_or_bail $slapd, '-f', $slapd_conf, '-h', "$ldap_url $ldaps_url";

View File

@ -93,6 +93,11 @@ recreate them if you need to make changes. "make sslfiles-clean" is required
in order to recreate the full set of keypairs and certificates. To rebuild in order to recreate the full set of keypairs and certificates. To rebuild
separate files, touch (or remove) the files in question and run "make sslfiles". separate files, touch (or remove) the files in question and run "make sslfiles".
Note
====
These certificates are also used in other tests, e.g. the LDAP tests.
TODO TODO
==== ====