|
| 1 | +mkdir tmp |
| 2 | +rm ../truststorefile.jks |
| 3 | +rm ../keystorefile.jks |
| 4 | +rm ../server.flume-keystore.p12 |
| 5 | +# Create the CA key and certificate |
| 6 | +openssl req -config rootca.conf -new -x509 -nodes -keyout tmp/flume-cacert.key -out tmp/flume-ca.crt -days 10960 |
| 7 | +# Create the trust store and import the certificate |
| 8 | +keytool -keystore ../truststorefile.jks -storetype jks -importcert -file 'tmp/flume-ca.crt' -keypass password -storepass password -alias flume-cacert -noprompt |
| 9 | +#Import the root certificate |
| 10 | +keytool -keystore ../keystorefile.jks -alias flume-ca -importcert -file tmp/flume-ca.crt -keypass password -storepass password -noprompt |
| 11 | +# Create the client private key in the client key store |
| 12 | +keytool -genkeypair -keyalg RSA -alias client -keystore ../keystorefile.jks -storepass password -keypass password -validity 10960 -keysize 2048 -dname "CN=client.flume, C=US" |
| 13 | +# Create a signing request for the client # |
| 14 | +keytool -keystore ../keystorefile.jks -alias client -certreq -file tmp/client.csr -keypass password -storepass password |
| 15 | +# Sign the client certificate |
| 16 | +openssl x509 -req -CA 'tmp/flume-ca.crt' -CAkey 'tmp/flume-cacert.key' -in tmp/client.csr -out tmp/client.crt_signed -days 10960 -CAcreateserial -passin pass:password |
| 17 | +# Verify the signed certificate |
| 18 | +openssl verify -CAfile 'tmp/flume-ca.crt' tmp/client.crt_signed |
| 19 | +#Import the client's signed certificate |
| 20 | +keytool -keystore ../keystorefile.jks -alias client -importcert -file tmp/client.crt_signed -keypass password -storepass password -noprompt |
| 21 | +#Verify the keystore |
| 22 | +keytool -list -v -keystore ../keystorefile.jks -storepass password |
| 23 | +# Create the server private key in the server key store |
| 24 | +keytool -genkeypair -keyalg RSA -alias server -keystore ../server.flume-keystore.p12 -storepass password -storetype PKCS12 -keypass password -validity 10960 -keysize 2048 -dname "CN=server.flume, C=US" |
| 25 | +# Create a signing request for the server # |
| 26 | +keytool -keystore ../server.flume-keystore.p12 -alias server -certreq -file tmp/server.csr -keypass password -storepass password |
| 27 | +# Sign the server certificate |
| 28 | +openssl x509 -req -CA 'tmp/flume-ca.crt' -CAkey 'tmp/flume-cacert.key' -in tmp/server.csr -out ../server.flume-crt.pem -days 10960 -CAcreateserial -passin pass:password |
| 29 | +# Extract the private key |
| 30 | +openssl pkcs12 -in ../server.flume-keystore.p12 -passin pass:password -nokeys -out ../server.flume.pem |
| 31 | +rm -rf tmp |
0 commit comments