| 1 |
Since OpenJDK 13.0.2/11.0.6 it is required that CA certificates have the extension "bc=ca:true". |
| 2 |
|
| 3 |
The keystores are generated in the following way: |
| 4 |
|
| 5 |
# Generates the server keystore. Note the BasicConstraint=CA:true extension. |
| 6 |
$ keytool -v -genkeypair -validity 36500 -keyalg RSA -keysize 2048 -keystore keystore.p12 -storetype pkcs12 -dname "CN=localhost, OU=Jetty, O=Webtide, L=Omaha, S=NE, C=US" -ext bc=ca:true -ext san=ip:127.0.0.1,ip:[::1],dns:localhost |
| 7 |
|
| 8 |
# Export the server certificate. |
| 9 |
$ keytool -v -export -keystore keystore.p12 -rfc -file server.crt |
| 10 |
|
| 11 |
# Export the server private key. |
| 12 |
$ openssl pkcs12 -in keystore.p12 -nodes -nocerts -out server.key |
| 13 |
|
| 14 |
# Generate the client keystore. |
| 15 |
$ keytool -v -genkeypair -validity 36500 -keyalg RSA -keysize 2048 -keystore client_keystore.p12 -storetype pkcs12 -dname "CN=client, OU=Jetty, O=Webtide, L=Omaha, S=NE, C=US" |
| 16 |
|
| 17 |
# Generate the Certificate Signing Request. |
| 18 |
$ keytool -certreq -file client.csr -keystore client_keystore.p12 |
| 19 |
|
| 20 |
# Sign the CSR. |
| 21 |
$ openssl x509 -req -days 36500 -in client.csr -CA server.crt -CAkey server.key -CAcreateserial -sha256 -out signed.crt |
| 22 |
|
| 23 |
# Import the server certificate into the client keystore. |
| 24 |
$ keytool -v -import -alias ca -file server.crt -keystore client_keystore.p12 |
| 25 |
|
| 26 |
# Import the signed CSR. |
| 27 |
$ keytool -import -file signed.crt -keystore client_keystore.p12 |