| 1 |
# |
| 2 |
# Licensed to the Apache Software Foundation (ASF) under one |
| 3 |
# or more contributor license agreements. See the NOTICE file |
| 4 |
# distributed with this work for additional information |
| 5 |
# regarding copyright ownership. The ASF licenses this file |
| 6 |
# to you under the Apache License, Version 2.0 (the |
| 7 |
# "License"); you may not use this file except in compliance |
| 8 |
# with the License. You may obtain a copy of the License at |
| 9 |
# |
| 10 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 |
# |
| 12 |
# Unless required by applicable law or agreed to in writing, |
| 13 |
# software distributed under the License is distributed on an |
| 14 |
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 |
# KIND, either express or implied. See the License for the |
| 16 |
# specific language governing permissions and limitations |
| 17 |
# under the License. |
| 18 |
# |
| 19 |
|
| 20 |
# The various PKCS12 SSL stores and certificates were created with the following commands: |
| 21 |
# Seems to require the JDK8 keytool. |
| 22 |
|
| 23 |
# Clean up existing files |
| 24 |
# ----------------------- |
| 25 |
rm -f *.crt *.csr *.keystore *.truststore |
| 26 |
|
| 27 |
# Create a key and self-signed certificate for the CA, to sign certificate requests and use for trust: |
| 28 |
# ---------------------------------------------------------------------------------------------------- |
| 29 |
keytool -storetype jks -keystore ca-jks.keystore -storepass password -keypass password -alias ca -genkey -keyalg "RSA" -keysize 2048 -dname "O=My Trusted Inc.,CN=my-ca.org" -validity 9999 -ext bc:c=ca:true |
| 30 |
keytool -storetype jks -keystore ca-jks.keystore -storepass password -alias ca -exportcert -rfc > ca.crt |
| 31 |
|
| 32 |
# Create a key pair for the server, and sign it with the CA: |
| 33 |
# ---------------------------------------------------------- |
| 34 |
keytool -storetype jks -keystore server-jks.keystore -storepass password -keypass password -alias server -genkey -keyalg "RSA" -keysize 2048 -dname "O=Server,CN=localhost" -validity 9999 -ext bc=ca:false -ext eku=sA |
| 35 |
|
| 36 |
keytool -storetype jks -keystore server-jks.keystore -storepass password -alias server -certreq -file server.csr |
| 37 |
keytool -storetype jks -keystore ca-jks.keystore -storepass password -alias ca -gencert -rfc -infile server.csr -outfile server.crt -validity 9999 -ext bc=ca:false -ext eku=sA |
| 38 |
|
| 39 |
keytool -storetype jks -keystore server-jks.keystore -storepass password -keypass password -importcert -alias ca -file ca.crt -noprompt |
| 40 |
keytool -storetype jks -keystore server-jks.keystore -storepass password -keypass password -importcert -alias server -file server.crt |
| 41 |
|
| 42 |
# Create trust store for the server, import the CA cert: |
| 43 |
# ------------------------------------------------------- |
| 44 |
keytool -storetype jks -keystore server-jks.truststore -storepass password -keypass password -importcert -alias ca -file ca.crt -noprompt |
| 45 |
|
| 46 |
# Create a key pair for a client, and sign it with the CA: |
| 47 |
# ---------------------------------------------------------- |
| 48 |
keytool -storetype jks -keystore client-jks.keystore -storepass password -keypass password -alias client -genkey -keyalg "RSA" -keysize 2048 -dname "O=Client,CN=client" -validity 9999 -ext bc=ca:false -ext eku=cA |
| 49 |
|
| 50 |
keytool -storetype jks -keystore client-jks.keystore -storepass password -alias client -certreq -file client.csr |
| 51 |
keytool -storetype jks -keystore ca-jks.keystore -storepass password -alias ca -gencert -rfc -infile client.csr -outfile client.crt -validity 9999 -ext bc=ca:false -ext eku=cA |
| 52 |
|
| 53 |
keytool -storetype jks -keystore client-jks.keystore -storepass password -keypass password -importcert -alias ca -file ca.crt -noprompt |
| 54 |
keytool -storetype jks -keystore client-jks.keystore -storepass password -keypass password -importcert -alias client -file client.crt |
| 55 |
|
| 56 |
# Create trust store for the client, import the CA cert: |
| 57 |
# ------------------------------------------------------- |
| 58 |
keytool -storetype jks -keystore client-jks.truststore -storepass password -keypass password -importcert -alias ca -file ca.crt -noprompt |
| 59 |
|
| 60 |
|
| 61 |
# Create a key and self-signed certificate for a second CA, to sign certificate requests and use for trust: |
| 62 |
# --------------------------------------------------------------------------------------------------------- |
| 63 |
|
| 64 |
keytool -storetype jks -keystore ca2-jks.keystore -storepass password -keypass password -alias ca2 -genkey -keyalg "RSA" -keysize 2048 -dname "O=My Other Trusted Inc.,CN=my-ca2.org" -validity 9999 -ext bc:c=ca:true |
| 65 |
keytool -storetype jks -keystore ca2-jks.keystore -storepass password -alias ca2 -exportcert -rfc > ca2.crt |
| 66 |
|
| 67 |
# Create a key pair for a second server, and sign it with the second CA: |
| 68 |
# ---------------------------------------------------------------------- |
| 69 |
keytool -storetype jks -keystore server2-jks.keystore -storepass password -keypass password -alias server2 -genkey -keyalg "RSA" -keysize 2048 -dname "O=Server2,CN=localhost" -validity 9999 -ext bc=ca:false -ext eku=sA |
| 70 |
|
| 71 |
keytool -storetype jks -keystore server2-jks.keystore -storepass password -alias server2 -certreq -file server2.csr |
| 72 |
keytool -storetype jks -keystore ca2-jks.keystore -storepass password -alias ca2 -gencert -rfc -infile server2.csr -outfile server2.crt -validity 9999 -ext bc=ca:false -ext eku=sA |
| 73 |
|
| 74 |
keytool -storetype jks -keystore server2-jks.keystore -storepass password -keypass password -importcert -alias ca2 -file ca2.crt -noprompt |
| 75 |
keytool -storetype jks -keystore server2-jks.keystore -storepass password -keypass password -importcert -alias server2 -file server2.crt |
| 76 |
|
| 77 |
# Create a file containing both CA certs to use for trusting both: |
| 78 |
# ---------------------------------------------------------------- |
| 79 |
cat ca.crt > ca-certs.crt |
| 80 |
cat ca2.crt >> ca-certs.crt |