Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 1 | FILE=sample |
| 2 | PASSWD=onaponap |
| 3 | CA_PASSWD=onaponap |
| 4 | SUBJ=/C=PL/ST=DL/L=Wroclaw/O=Nokia/OU=MANO |
| 5 | CA=trust |
| 6 | |
| 7 | sign: $(FILE).crt |
| 8 | |
| 9 | clean: |
| 10 | rm -f *.crt *.key *.srl *.csr *.pkcs12 |
| 11 | |
| 12 | generate-ca-certificate: $(CA).crt |
| 13 | |
| 14 | generate-private-key: $(FILE).key |
| 15 | |
| 16 | create-public-key: $(FILE).pub |
| 17 | |
| 18 | create-sign-request: $(FILE).csr |
| 19 | |
| 20 | create-key-store: $(FILE).ks.pkcs12 |
| 21 | |
| 22 | create-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) |