Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to setup a custom truststore for the JVM #25

Merged
merged 2 commits into from
Feb 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ add_conf_if_not_exists(){
local CONFIG=$2
# This isn't completely robust but all input is controlled by us,
# we pass the CONFIG, not the user.
local OPTION_NAME="$(sed -r -e 's/^\s*([^=]+)=.*/\1/' <<<"$CONFIG")"
local OPTION_NAME
OPTION_NAME="$(sed -r -e 's/^\s*([^=]+)=.*/\1/' <<<"$CONFIG")"
if ! grep -sqE "^\s*${OPTION_NAME}=" "$FILE"; then
cat <<EOF >>"$FILE"
$CONFIG
Expand Down Expand Up @@ -630,6 +631,25 @@ EOF
unset FILECONTENT_REGISTRY_KEYTAB
fi
;;
FILECONTENT_JVM_SSL_TRUSTSTORE)
if [[ -n $FILECONTENT_JVM_SSL_TRUSTSTORE ]]; then
DECODE="cat"
if ! echo -n "$FILECONTENT_JVM_SSL_TRUSTSTORE" | tr -d '\n' | grep -vsqE "$BASE64_REGEXP" ; then
DECODE="base64 -d"
fi
$DECODE <<< "$FILECONTENT_JVM_SSL_TRUSTSTORE" > /data/jvm-truststore.jks
echo "File created. Sha256sum: $(sha256sum /data/jvm-truststore.jks)"
chmod 400 /data/jvm-truststore.jks
export LENSES_OPTS="$LENSES_OPTS -Djavax.net.ssl.trustStore=/data/jvm-truststore.jks"
unset FILECONTENT_JVM_SSL_TRUSTSTORE
fi
;;
FILECONTENT_JVM_SSL_TRUSTSTORE_PASSWORD)
if [[ -n $FILECONTENT_JVM_SSL_TRUSTSTORE_PASSWORD ]]; then
export LENSES_OPTS="$LENSES_OPTS -Djavax.net.ssl.trustStorePassword=${FILECONTENT_JVM_SSL_TRUSTSTORE_PASSWORD}"
unset FILECONTENT_JVM_SSL_TRUSTSTORE_PASSWORD
fi
;;
*)
echo "Unknown filecontent variable $var was provided but won't be used."
;;
Expand Down Expand Up @@ -731,6 +751,7 @@ if [[ "$C_UID" == 0 ]]; then
/data/logback.xml \
/data/keystore.jks \
/data/truststore.jks \
/data/jvm-truststore.jks \
/data/jaas.conf \
/data/krb5.conf \
/data/keytab
Expand All @@ -746,6 +767,7 @@ if [[ "$C_UID" == 0 ]]; then
/data/logback.xml \
/data/keystore.jks \
/data/truststore.jks \
/data/jvm-truststore.jks \
/data/jaas.conf \
/data/krb5.conf \
/data/keytab
Expand Down