Test: add documentation and rebuild files
[vpnc.git] / test / Makefile
blob2f0cad3d89b01053c8dc24bbea0e9cab1adaaaf8
1 # Makefile to rebuild certificate chain for VPNC test.
2 # Copyright (C) 2013 Antonio Borneo
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 OPENSSL = openssl
20 CFG = openssl.cnf
21 TIME = -days 7120
23 # default targets empty.
24 all default clean:
26 # target to rebuild everything
27 rebuild: ca_list.pem cert3.pem sig_data.bin
29 ca1.key cert1.key:
30 $(OPENSSL) genrsa -out $@ 4096
32 ca2.key ca3.key cert0.key cert2.key cert3.key:
33 $(OPENSSL) genrsa -out $@ 2048
35 ca1.pem: ca1.key
36 ca2.pem: ca2.key
37 ca3.pem: ca3.key
39 ca%.pem: ca%.key
40 $(OPENSSL) req -new -x509 -key $< -out $@ $(TIME) -batch -text \
41 -subj "/OU=Root Certification Authority/CN="$@
43 ca_list.pem: ca1.pem ca2.pem ca3.pem
44 cat $^ > $@
46 CHAIN_SIGN = $(OPENSSL) req -new -key $(2) -batch -subj "/OU=Cert/CN="$(1) \
47 | $(OPENSSL) x509 -req $(TIME) -CA $(3) -CAkey $(4) -set_serial 01 \
48 -out $(1) -text -extfile $(CFG) -extensions usr
50 cert0.pem: cert0.key ca3.pem ca3.key $(CFG)
51 $(call CHAIN_SIGN,cert0.pem,cert0.key,ca3.pem,ca3.key)
53 cert1.pem: cert1.key cert0.pem cert0.key $(CFG)
54 $(call CHAIN_SIGN,cert1.pem,cert1.key,cert0.pem,cert0.key)
56 cert2.pem: cert2.key cert1.pem cert1.key $(CFG)
57 $(call CHAIN_SIGN,cert2.pem,cert2.key,cert1.pem,cert1.key)
59 cert3.pem: cert3.key cert2.pem cert2.key $(CFG)
60 $(call CHAIN_SIGN,cert3.pem,cert3.key,cert2.pem,cert2.key)
62 $(CFG):
63 echo -e '[ usr ]\nbasicConstraints=CA:TRUE' > $(CFG)
65 dec_data.bin:
66 dd if=/dev/urandom of=$@ bs=256 count=1
68 sig_data.bin: dec_data.bin cert0.key
69 $(OPENSSL) rsautl -decrypt -in $< -out $@ -inkey cert0.key -raw
71 clean_build:
72 rm -f *.pem $(CFG) sig_data.bin
74 clean_key:
75 rm -f *.key dec_data.bin
77 clean_all: clean_build clean_key