source: mod_gnutls/test/test_ca.mk @ 21181b2

debian/masterdebian/stretch-backportsupstream
Last change on this file since 21181b2 was 5725dca, checked in by Thomas Klute <thomas2.klute@…>, 3 years ago

Test suite: Consistent use of @VAR@ vs. $(VAR)

Makefile.am will always be processed by autotools, so @VAR@ where
possible is the way to go. On the other hand, test_ca.mk should be
usable as a general collection of make rules and use $(VAR).

  • Property mode set to 100644
File size: 4.0 KB
Line 
1#!/usr/bin/make -f
2# Authors:
3# Daniel Kahn Gillmor <dkg@fifthhorseman.net>
4# Thomas Klute <thomas2.klute@uni-dortmund.de>
5
6# General rules to set up a miniature CA & server & client environment
7# for the test suite
8
9%.template: $(srcdir)/%.template.in
10        sed s/__HOSTNAME__/$(TEST_HOST)/ < $< > $@
11
12%.uid: $(srcdir)/%.uid.in
13        sed s/__HOSTNAME__/$(TEST_HOST)/ < $< > $@
14
15%/secret.key:
16        mkdir -p $(dir $@)
17        chmod 0700 $(dir $@)
18        certtool --generate-privkey > $@
19
20%/secring.gpg: %.uid %/secret.key
21        rm -f $(dir $@)pubring.gpg $(dir $@)secring.gpg $(dir $@)trustdb.gpg
22        PEM2OPENPGP_EXPIRATION=86400 PEM2OPENPGP_USAGE_FLAGS=authenticate,certify,sign pem2openpgp "$$(cat $<)" < $(dir $@)secret.key | GNUPGHOME=$(dir $@) gpg --import
23        printf "%s:6:\n" "$$(GNUPGHOME=$(dir $@) gpg --with-colons --list-secret-keys --fingerprint | grep ^fpr: | cut -f 10 -d :)" | GNUPGHOME=$(dir $@) gpg --import-ownertrust
24
25%/gpg.conf: %/secring.gpg
26        printf "default-key %s\n" "$$(GNUPGHOME=$(dir $@) gpg --with-colons --list-secret-keys --fingerprint | grep ^fpr: | cut -f 10 -d :)" > $@
27
28%/secret.pgp: %/secring.gpg
29        GNUPGHOME=$(dir $@) gpg --armor --batch --no-tty --yes --export-secret-key "$$(GNUPGHOME=$(dir $@) gpg --with-colons --list-secret-keys --fingerprint | grep ^fpr: | cut -f 10 -d :)" > $@
30
31%/minimal.pgp: %/secring.gpg
32        GNUPGHOME=$(dir $@) gpg --armor --export "$$(GNUPGHOME=$(dir $@) gpg --with-colons --list-secret-keys --fingerprint | grep ^fpr: | cut -f 10 -d :)" > $@
33
34# Import and signing modify the shared keyring, which leads to race
35# conditions with parallel make. Locking avoids this problem.
36%/cert.pgp: %/minimal.pgp authority/gpg.conf
37        GNUPGHOME=authority $(GPG_FLOCK) gpg --import $<
38        GNUPGHOME=authority $(GPG_FLOCK) gpg --batch --sign-key --no-tty --yes "$$(GNUPGHOME=$(dir $@) gpg --with-colons --list-secret-keys --fingerprint | grep ^fpr: | cut -f 10 -d :)"
39        GNUPGHOME=authority gpg --armor --export "$$(GNUPGHOME=$(dir $@) gpg --with-colons --list-secret-keys --fingerprint | grep ^fpr: | cut -f 10 -d :)" > $@
40
41# special cases for the authorities' root certs:
42authority/x509.pem: authority.template authority/secret.key
43        certtool --generate-self-signed --load-privkey authority/secret.key --template authority.template > $@
44rogueca/x509.pem: $(srcdir)/rogueca.template rogueca/secret.key
45        certtool --generate-self-signed --load-privkey rogueca/secret.key --template $(srcdir)/rogueca.template > $@
46
47%/cert-request: %.template %/secret.key
48        certtool --generate-request --load-privkey $(dir $@)secret.key --template $< > $@
49
50# normal case: certificates signed by test CA
51%/x509.pem: %.template %/cert-request authority/secret.key authority/x509.pem
52        certtool --generate-certificate --load-ca-certificate authority/x509.pem --load-ca-privkey authority/secret.key --load-request $(dir $@)cert-request --template $< > $@
53
54# error case: certificates signed by rogue CA
55rogue%/x509.pem: rogue%.template rogue%/cert-request rogueca/x509.pem
56        certtool --generate-certificate --load-ca-certificate rogueca/x509.pem --load-ca-privkey rogueca/secret.key --load-request $(dir $@)cert-request --template $< > $@
57
58%/softhsm.conf: %/secret.key
59        echo "0:$(dir $@)softhsm.db" > $@
60
61%/softhsm.db: %/x509.pem %/secret.key %/softhsm.conf
62        SOFTHSM="$(SOFTHSM)" \
63        SOFTHSM_CONF="$(dir $@)softhsm.conf" \
64        $(srcdir)/softhsm.bash init $(dir $@)secret.key $(dir $@)x509.pem
65
66%/softhsm2.conf: %/secret.key
67        echo "objectstore.backend = file" > $@
68        echo "directories.tokendir = $(dir $@)softhsm2.db" >> $@
69
70%/softhsm2.db: %/x509.pem %/secret.key %/softhsm2.conf
71        mkdir -p $@
72        SOFTHSM="$(SOFTHSM)" \
73        SOFTHSM2_CONF="$(dir $@)softhsm2.conf" \
74        $(srcdir)/softhsm.bash init $(dir $@)secret.key $(dir $@)x509.pem
75
76# Generate CRL revoking a certain certificate. Currently used to
77# revoke the server certificate and check if setting the CRL as
78# GnuTLSProxyCRLFile causes the connection to the back end server to
79# fail.
80%/crl.pem: %/x509.pem ${srcdir}/%-crl.template
81        certtool --generate-crl \
82                --load-ca-privkey authority/secret.key \
83                --load-ca-certificate authority/x509.pem \
84                --load-certificate $< \
85                --template "${srcdir}/$(*)-crl.template" \
86                > $@
Note: See TracBrowser for help on using the repository browser.