@@ -23,6 +23,8 @@ function importKeyCert() {
2323
2424 # Import the private key and certificate into new keystore
2525 if [ -f " ${CERT_FOLDER} /${KEY_FILE} " ] && [ -f " ${CERT_FOLDER} /${CRT_FILE} " ]; then
26+ # Mounted certificates found. Assume the user wants to overwrite any existing keystore
27+ # and add these certificates
2628 echo " Found mounted TLS certificates, generating keystore"
2729 setPasswords PASSWORD TRUSTSTORE_PASSWORD
2830 mkdir -p /output/resources/security
@@ -44,7 +46,7 @@ function importKeyCert() {
4446 fi
4547
4648 # Since we are creating new keystore, always write new password to a file
47- sed " s|REPLACE|$PASSWORD |g" $SNIPPETS_SOURCE /keystore.xml > $SNIPPETS_TARGET_DEFAULTS /keystore.xml
49+ sed " s|REPLACE|$PASSWORD |g" $SNIPPETS_SOURCE /keystore.xml > $keystorePathOverride
4850
4951 # Add mounted CA to the truststore
5052 if [ -f " ${CERT_FOLDER} /${CA_FILE} " ]; then
@@ -70,10 +72,10 @@ function importKeyCert() {
7072 rm -rf /tmp/certs
7173 fi
7274
73- # Add the keystore password to server configuration
74- if [ ! -e $keystorePath ]; then
75+ # If no keystore has been created, add a keystore password to server configuration
76+ if [ ! -e " $keystorePathDefault " ] && [ ! -e " $keystorePathOverride " ]; then
7577 setPasswords PASSWORD TRUSTSTORE_PASSWORD
76- sed " s|REPLACE|$PASSWORD |g" $SNIPPETS_SOURCE /keystore.xml > $SNIPPETS_TARGET_DEFAULTS /keystore.xml
78+ sed " s|REPLACE|$PASSWORD |g" $SNIPPETS_SOURCE /keystore.xml > $keystorePathDefault
7779 fi
7880 if [ -e $TRUSTSTORE_FILE ]; then
7981 setPasswords PASSWORD TRUSTSTORE_PASSWORD
@@ -89,7 +91,8 @@ SNIPPETS_SOURCE=/opt/ol/helpers/build/configuration_snippets
8991SNIPPETS_TARGET_DEFAULTS=/config/configDropins/defaults
9092SNIPPETS_TARGET_OVERRIDES=/config/configDropins/overrides
9193
92- keystorePath=" $SNIPPETS_TARGET_DEFAULTS /keystore.xml"
94+ keystorePathDefault=" $SNIPPETS_TARGET_DEFAULTS /keystore.xml"
95+ keystorePathOverride=" $SNIPPETS_TARGET_OVERRIDES /keystore.xml"
9396
9497if [ " $SSL " = " true" ] || [ " $TLS " = " true" ]; then
9598 cp $SNIPPETS_SOURCE /tls.xml $SNIPPETS_TARGET_OVERRIDES /tls.xml
0 commit comments