-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Http: use FIPS complaiant keystore and truststore
- Loading branch information
1 parent
a02012d
commit 13b944d
Showing
9 changed files
with
65 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
== Certificate for HTTPS | ||
|
||
Server keystore has to contain server certificate. It is possible to use self-signed certificate created by following command: | ||
Server keystore has to contain server certificate. | ||
|
||
`keytool -genkeypair -keystore keystore.p12 -storetype PKCS12 -storepass changeit -alias localhost -keyalg RSA -keysize 2048 -validity 99999 -dname "CN=localhost"' | ||
=== How to generate new keystore and truststore | ||
|
||
Delete folder `common/src/main/resources/jsse` and run the script `common/generate-certs.sh` to generate new keystore and truststore. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -x | ||
|
||
invocationDir="$(pwd)" | ||
workDir="target/openssl-work" | ||
destinationDir="src/main/resources/jsse" | ||
keySize=2048 | ||
days=10000 | ||
extFile="$(pwd)/v3.ext" | ||
encryptionAlgo="aes-256-cbc" | ||
|
||
if [[ -n "${JAVA_HOME}" ]] ; then | ||
keytool="$JAVA_HOME/bin/keytool" | ||
elif ! [[ -x "$(command -v keytool)" ]] ; then | ||
echo 'Error: Either add keytool to PATH or set JAVA_HOME' >&2 | ||
exit 1 | ||
else | ||
keytool="keytool" | ||
fi | ||
|
||
if ! [[ -x "$(command -v openssl)" ]] ; then | ||
echo 'Error: openssl is not installed.' >&2 | ||
exit 1 | ||
fi | ||
|
||
mkdir -p "$workDir" | ||
mkdir -p "$destinationDir" | ||
|
||
# Certificate authority | ||
openssl genrsa -out "$workDir/ca.key" $keySize | ||
openssl req -x509 -new -subj '/O=apache.org/OU=eng (NOT FOR PRODUCTION)/CN=ca' -key "$workDir/ca.key" -nodes -out "$workDir/ca.pem" -days $days -extensions v3_req | ||
openssl req -new -subj '/O=apache.org/OU=eng (NOT FOR PRODUCTION)/CN=ca' -x509 -key "$workDir/ca.key" -days $days -out "$workDir/ca.crt" | ||
|
||
for actor in localhost; do | ||
# Generate keys | ||
openssl genrsa -out "$workDir/$actor.key" $keySize | ||
|
||
# Generate certificates | ||
openssl req -new -subj "/O=apache.org/OU=eng (NOT FOR PRODUCTION)/CN=$actor" -key "$workDir/$actor.key" -out "$workDir/$actor.csr" | ||
openssl x509 -req -in "$workDir/$actor.csr" -extfile "$extFile" -CA "$workDir/ca.pem" -CAkey "$workDir/ca.key" -CAcreateserial -days $days -out "$workDir/$actor.crt" | ||
|
||
# Export keystores | ||
openssl pkcs12 -export -in "$workDir/$actor.crt" -inkey "$workDir/$actor.key" -certfile "$workDir/ca.crt" -name "$actor" -out "$destinationDir/$actor-keystore.pkcs12" -passout pass:"${actor}-keystore-password" -keypbe "$encryptionAlgo" -certpbe "$encryptionAlgo" | ||
done | ||
|
||
|
||
# Truststore | ||
"$keytool" -import -file "$workDir/localhost.crt" -alias localhost -noprompt -keystore "$destinationDir/client-truststore.pkcs12" -storepass "client-truststore-password" | ||
"$keytool" -import -file "$workDir/ca.crt" -alias ca -noprompt -keystore "$destinationDir/client-truststore.pkcs12" -storepass "client-truststore-password" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+2.19 KB
integration-test-groups/http/common/src/main/resources/jsse/client-truststore.pkcs12
Binary file not shown.
Binary file removed
BIN
-2.36 KB
integration-test-groups/http/common/src/main/resources/jsse/keystore.p12
Binary file not shown.
Binary file added
BIN
+3.55 KB
integration-test-groups/http/common/src/main/resources/jsse/localhost-keystore.pkcs12
Binary file not shown.
Binary file removed
BIN
-1018 Bytes
integration-test-groups/http/common/src/main/resources/jsse/truststore.jks
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
authorityKeyIdentifier = keyid, issuer | ||
basicConstraints = CA:FALSE | ||
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment |