1 all: agent1-cert.pem agent2-cert.pem agent3-cert.pem agent4-cert.pem ca2-crl.pem
5 # Create Certificate Authority: ca1
6 # ('password' is used for the CA password.)
9 openssl req -new -x509 -days 9999 -config ca1.cnf -keyout ca1-key.pem -out ca1-cert.pem
12 # Create Certificate Authority: ca2
13 # ('password' is used for the CA password.)
16 openssl req -new -x509 -days 9999 -config ca2.cnf -keyout ca2-key.pem -out ca2-cert.pem
17 echo '01' > ca2-serial
18 touch ca2-database.txt
22 # agent1 is signed by ca1.
26 openssl genrsa -out agent1-key.pem 1024
28 agent1-csr.pem: agent1.cnf agent1-key.pem
29 openssl req -new -config agent1.cnf -key agent1-key.pem -out agent1-csr.pem
31 agent1-cert.pem: agent1-csr.pem ca1-cert.pem ca1-key.pem
34 -passin "pass:password" \
41 agent1-verify: agent1-cert.pem ca1-cert.pem
42 openssl verify -CAfile ca1-cert.pem agent1-cert.pem
46 # agent2 has a self signed cert
48 # Generate new private key
50 openssl genrsa -out agent2-key.pem 1024
52 # Create a Certificate Signing Request for the key
53 agent2-csr.pem: agent2-key.pem agent2.cnf
54 openssl req -new -config agent2.cnf -key agent2-key.pem -out agent2-csr.pem
56 # Create a Certificate for the agent.
57 agent2-cert.pem: agent2-csr.pem agent2-key.pem
61 -signkey agent2-key.pem \
64 agent2-verify: agent2-cert.pem
65 openssl verify -CAfile agent2-cert.pem agent2-cert.pem
68 # agent3 is signed by ca2.
72 openssl genrsa -out agent3-key.pem 1024
74 agent3-csr.pem: agent3.cnf agent3-key.pem
75 openssl req -new -config agent3.cnf -key agent3-key.pem -out agent3-csr.pem
77 agent3-cert.pem: agent3-csr.pem ca2-cert.pem ca2-key.pem
80 -passin "pass:password" \
87 agent3-verify: agent3-cert.pem ca2-cert.pem
88 openssl verify -CAfile ca2-cert.pem agent3-cert.pem
92 # agent4 is signed by ca2 (client cert)
96 openssl genrsa -out agent4-key.pem 1024
98 agent4-csr.pem: agent4.cnf agent4-key.pem
99 openssl req -new -config agent4.cnf -key agent4-key.pem -out agent4-csr.pem
101 agent4-cert.pem: agent4-csr.pem ca2-cert.pem ca2-key.pem
104 -passin "pass:password" \
109 -extfile agent4.cnf \
110 -extensions ext_key_usage \
113 agent4-verify: agent4-cert.pem ca2-cert.pem
114 openssl verify -CAfile ca2-cert.pem agent4-cert.pem
117 # Make CRL with agent4 being rejected
119 ca2-crl.pem: ca2-key.pem ca2-cert.pem ca2.cnf
120 openssl ca -revoke agent4-cert.pem \
121 -keyfile ca2-key.pem \
125 -keyfile ca2-key.pem \
132 rm -f *.pem *.srl ca2-database.txt ca2-serial
134 test: agent1-verify agent2-verify agent3-verify agent4-verify
137 .PHONY: all clean test agent1-verify agent2-verify agent3-verify agent4-verify