@@ -2,6 +2,7 @@ PASSWORD=changeit
22KEYSTORE =keystore.jks
33HOSTNAME =localhost
44CLIENTNAME =cid
5+ CLIENT_PRIVATE_KEY ="${CLIENTNAME}_pk"
56
67# CN = Common Name
78# OU = Organization Unit
@@ -59,12 +60,12 @@ create-truststore: export-authority
5960
6061add-client :
6162 # Generate client certificate
62- keytool -genkey -alias $(CLIENTNAME ) -ext san=dns:localhost,ip:127.0.0.1 \
63+ keytool -genkey -alias $(CLIENT_PRIVATE_KEY ) -ext san=dns:localhost,ip:127.0.0.1 \
6364 -keyalg RSA -keysize 4096 -sigalg SHA512withRSA -keypass $(PASSWORD ) \
6465 -validity 3650 -dname $(DNAME_CLIENT ) \
6566 -keystore $(TRUSTSTORE ) -storepass $(PASSWORD )
6667 # Generate a host certificate signing request
67- keytool -certreq -alias $(CLIENTNAME ) -ext san=dns:localhost,ip:127.0.0.1 -ext BC=ca:true \
68+ keytool -certreq -alias $(CLIENT_PRIVATE_KEY ) -ext san=dns:localhost,ip:127.0.0.1 -ext BC=ca:true \
6869 -keyalg RSA -keysize 4096 -sigalg SHA512withRSA \
6970 -validity 3650 -file " $( CLIENTNAME) .csr" \
7071 -keystore $(TRUSTSTORE ) -storepass $(PASSWORD )
@@ -78,10 +79,13 @@ add-client:
7879 -file " $( CLIENTNAME) .crt" \
7980 -keystore $(TRUSTSTORE ) -storepass $(PASSWORD )
8081 # Export private certificate for importing into a browser
81- keytool -importkeystore -srcalias $(CLIENTNAME ) -ext san=dns:localhost,ip:127.0.0.1 \
82+ keytool -importkeystore -srcalias $(CLIENT_PRIVATE_KEY ) -ext san=dns:localhost,ip:127.0.0.1 \
8283 -srckeystore $(TRUSTSTORE ) -srcstorepass $(PASSWORD ) \
8384 -destkeystore " $( CLIENTNAME) .p12" -deststorepass $(PASSWORD ) \
8485 -deststoretype PKCS12
86+ # Delete client private key as truststore should not contain any private keys
87+ keytool -delete -alias $(CLIENT_PRIVATE_KEY ) \
88+ -keystore $(TRUSTSTORE ) -storepass $(PASSWORD )
8589
8690clean :
8791 # Remove generated artifacts
0 commit comments