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
23 # default targets empty.
26 # target to rebuild everything
27 rebuild
: ca_list.pem cert3.pem sig_data.bin
30 $(OPENSSL
) genrsa
-out
$@
4096
32 ca2.key ca3.key cert0.key cert2.key cert3.key
:
33 $(OPENSSL
) genrsa
-out
$@
2048
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
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
)
63 echo
-e
'[ usr ]\nbasicConstraints=CA:TRUE' > $(CFG
)
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
72 rm -f
*.pem
$(CFG
) sig_data.bin
75 rm -f
*.key dec_data.bin
77 clean_all
: clean_build clean_key