Skip to content

Commit

Permalink
Fix Certificate Import Issue by Generating Unique Aliases in cacert s…
Browse files Browse the repository at this point in the history
…cript
  • Loading branch information
gdams committed Aug 27, 2024
1 parent ccefcfd commit 3e06db3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docker_templates/entrypoint.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ if [ -n "$USE_SYSTEM_CA_CERTS" ]; then
csplit -s -z -b %02d.crt -f "$tmp_dir/$BASENAME-" "$i" '/-----BEGIN CERTIFICATE-----/' '{*}'

for crt in "$tmp_dir/$BASENAME"-*; do
# Create an alias for the certificate
ALIAS=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p')
# Create a unique alias for the certificate
CN=$(openssl x509 -in "$crt" -noout -subject -nameopt -space_eq | sed -n 's/^.*CN=\([^,]*\).*$/\1/p')
SERIAL=$(openssl x509 -in "$crt" -noout -serial | sed -n 's/^serial=\(.*\)$/\1/p')
ALIAS="${CN}_${SERIAL}"

# Add the certificate to the JVM truststore
keytool -import -noprompt -alias "$ALIAS" -file "$crt" -keystore "$JRE_CACERTS_PATH" -storepass changeit >/dev/null
Expand Down

0 comments on commit 3e06db3

Please sign in to comment.