-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #205 from medizininformatik-initiative/feature/203…
…-support-self-signed-certificates #203 - Support self-signed certificates
- Loading branch information
Showing
3 changed files
with
53 additions
and
1 deletion.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
TRUSTSTORE_FILE="/opt/codex-feasibility-backend/truststore/self-signed-truststore.jks" | ||
TRUSTSTORE_PASS=${TRUSTSTORE_PASS:-changeit} | ||
KEY_PASS=${KEY_PASS:-changeit} | ||
|
||
shopt -s nullglob | ||
IFS=$'\n' | ||
ca_files=(certs/*.pem) | ||
|
||
if [ ! "${#ca_files[@]}" -eq 0 ]; then | ||
|
||
echo "# At least one CA file with extension *.pem found in certs folder -> starting feasibility backend with own CAs" | ||
|
||
if [[ -f "$TRUSTSTORE_FILE" ]]; then | ||
echo "## Truststore already exists -> resetting truststore" | ||
rm "$TRUSTSTORE_FILE" | ||
fi | ||
|
||
keytool -genkey -alias self-signed-truststore -keyalg RSA -keystore "$TRUSTSTORE_FILE" -storepass "$TRUSTSTORE_PASS" -keypass "$KEY_PASS" -dname "CN=self-signed,OU=self-signed,O=self-signed,L=self-signed,S=self-signed,C=TE" | ||
keytool -delete -alias self-signed-truststore -keystore "$TRUSTSTORE_FILE" -storepass "$TRUSTSTORE_PASS" -noprompt | ||
|
||
for filename in "${ca_files[@]}"; do | ||
|
||
echo "### ADDING CERT: $filename" | ||
keytool -delete -alias "$filename" -keystore "$TRUSTSTORE_FILE" -storepass "$TRUSTSTORE_PASS" -noprompt > /dev/null 2>&1 | ||
keytool -importcert -alias "$filename" -file "$filename" -keystore "$TRUSTSTORE_FILE" -storepass "$TRUSTSTORE_PASS" -noprompt | ||
|
||
done | ||
|
||
java -Djavax.net.ssl.trustStore="$TRUSTSTORE_FILE" -Djavax.net.ssl.trustStorePassword="$TRUSTSTORE_PASS" -jar feasibility-gui-backend.jar | ||
else | ||
echo "# No CA *.pem cert files found in /opt/codex-feasibility-backend/certs -> starting feasibility backend without own CAs" | ||
java -jar feasibility-gui-backend.jar | ||
fi |