blob: a32d30dd0a4e93302512f81788d0f1d5dd77001d [file] [log] [blame]
Gary Wu9abb61c2018-09-27 10:38:50 -07001FILE=sample
2PASSWD=onaponap
3CA_PASSWD=onaponap
4SUBJ=/C=PL/ST=DL/L=Wroclaw/O=Nokia/OU=MANO
5CA=trust
6
7sign: $(FILE).crt
8
9clean:
10 rm -f *.crt *.key *.srl *.csr *.pkcs12
11
12generate-ca-certificate: $(CA).crt
13
14generate-private-key: $(FILE).key
15
16create-public-key: $(FILE).pub
17
18create-sign-request: $(FILE).csr
19
20create-key-store: $(FILE).ks.pkcs12
21
22create-trust-store: $(CA).crt
23 openssl pkcs12 -export -in $(CA).crt -CAfile $(CA).crt -out $(CA).pkcs12 -nokeys -noiter -nomaciter -passout pass:$(PASSWD)
24
25$(CA).crt:
26 openssl req -new -x509 -keyout $(CA).key -out $(CA).crt -days 365 -passout pass:$(CA_PASSWD) -subj "$(SUBJ)"
27
28$(FILE).key:
29 openssl genpkey -algorithm RSA -out $(FILE).key -pkeyopt rsa_keygen_bits:2048
30
31$(FILE).pub: $(FILE).key
32 openssl x509 -req -days 360 -in client.csr -CA $(CA).crt -CAkey $(CA).key -CAcreateserial -out client.crt
33
34$(FILE).csr: $(FILE).key
35 openssl req -new -sha256 -key $(FILE).key -out $(FILE).csr -subj "$(SUBJ)"
36
37$(FILE).crt: $(CA).crt $(FILE).csr
38 openssl x509 -req -days 360 -in $(FILE).csr -CA $(CA).crt -CAkey $(CA).key -out $(FILE).crt -CAcreateserial -passin pass:$(CA_PASSWD)
39
40$(FILE).ks.pkcs12: $(FILE).key $(FILE).crt $(CA).crt
41 openssl pkcs12 -export -in $(FILE).crt -inkey $(FILE).key -CAfile $(CA).crt -out $(FILE).ks.pkcs12 -noiter -nomaciter -passout pass:$(PASSWD)