e2e: strict-X.509-compatible test CA
This commit is contained in:
1 parent
cbd85c1e30
commit
07ff88c18d
1 file changed
+24
-3
+24
-3
@@ -7,14 +7,35 @@
|
||||
{ mailmig, nixos-mailserver }:
|
||||
{ pkgs, lib, ... }:
|
||||
let
|
||||
# Python 3.13 verifies strictly (VERIFY_X509_STRICT): the CA needs keyUsage,
|
||||
# leaves need SKI/AKI.
|
||||
certs = pkgs.runCommand "mailmig-test-certs" { nativeBuildInputs = [ pkgs.openssl ]; } ''
|
||||
mkdir $out && cd $out
|
||||
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -nodes \
|
||||
-keyout ca.key -out ca.crt -days 3650 -subj "/CN=mailmig test CA"
|
||||
cat > ca.cnf <<EOF
|
||||
[req]
|
||||
distinguished_name = dn
|
||||
x509_extensions = v3_ca
|
||||
prompt = no
|
||||
[dn]
|
||||
CN = mailmig test CA
|
||||
[v3_ca]
|
||||
basicConstraints = critical,CA:TRUE
|
||||
keyUsage = critical,keyCertSign,cRLSign
|
||||
subjectKeyIdentifier = hash
|
||||
EOF
|
||||
openssl req -x509 -config ca.cnf -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -nodes \
|
||||
-keyout ca.key -out ca.crt -days 3650
|
||||
for h in old new; do
|
||||
openssl req -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -nodes \
|
||||
-keyout $h.key -out $h.csr -subj "/CN=$h.test"
|
||||
printf 'subjectAltName=DNS:%s.test\nextendedKeyUsage=serverAuth\nkeyUsage=digitalSignature\nbasicConstraints=CA:FALSE\n' $h > $h.ext
|
||||
cat > $h.ext <<EOF
|
||||
subjectAltName = DNS:$h.test
|
||||
extendedKeyUsage = serverAuth
|
||||
keyUsage = critical,digitalSignature
|
||||
basicConstraints = critical,CA:FALSE
|
||||
subjectKeyIdentifier = hash
|
||||
authorityKeyIdentifier = keyid
|
||||
EOF
|
||||
openssl x509 -req -in $h.csr -CA ca.crt -CAkey ca.key -CAcreateserial \
|
||||
-out $h.crt -days 3650 -extfile $h.ext
|
||||
done
|
||||
|
||||
Reference in new issue
Block a user