-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: fix certificat creation in entry point
- Loading branch information
1 parent
7879f67
commit e2bd629
Showing
3 changed files
with
30 additions
and
17 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
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,27 +1,40 @@ | ||
#!/bin/sh | ||
|
||
# Setup directory for certificates | ||
CERT_DIR=./ssl | ||
CERT_DIR=./data/ssl | ||
mkdir -p "$CERT_DIR" | ||
|
||
# Paths to the certificate and key files | ||
CERT_FILE="$CERT_DIR/tls.crt" | ||
KEY_FILE="$CERT_DIR/tls.key" | ||
|
||
# Check if the first argument is "start-operator" | ||
if [ "$1" = "start-operator" ]; then | ||
# Generate a self-signed SSL certificate only if it doesn't exist | ||
if [ ! -f "$CERT_FILE" ] || [ ! -f "$KEY_FILE" ]; then | ||
echo "Certificate or key file not found. Generating new SSL certificate and key." | ||
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \ | ||
-keyout "$KEY_FILE" -out "$CERT_FILE" \ | ||
-subj "/C=CN/ST=GD/L=SZ/O=$CN, Inc./CN=$CN" \ | ||
-addext "subjectAltName = DNS:$CN" \ | ||
-CA $CA -CAkey $CAkey | ||
else | ||
echo "Existing SSL certificate and key found. Using them." | ||
fi | ||
|
||
# Generate a self-signed SSL certificate only if it doesn't exist | ||
if [ ! -f "$CERT_FILE" ] || [ ! -f "$KEY_FILE" ]; then | ||
echo "Certificate or key file not found. Generating new SSL certificate and key." | ||
if [ -z "$CN" ] || [ -z "$CA" ] || [ -z "$CAkey" ]; then | ||
echo "Generating self-signed certificate..." | ||
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \ | ||
-keyout "$KEY_FILE" -out "$CERT_FILE" \ | ||
-subj "/C=CN/ST=GD/L=SZ/O=localhost, Inc./CN=localhost" || { | ||
echo "Error: Failed to generate self-signed certificate." | ||
exit 1 | ||
} | ||
else | ||
echo "Generating CA-signed certificate..." | ||
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \ | ||
-keyout "$KEY_FILE" -out "$CERT_FILE" \ | ||
-subj "/C=CN/ST=GD/L=SZ/O=$CN, Inc./CN=$CN" \ | ||
-addext "subjectAltName=DNS:$CN" \ | ||
-CA "$CA" -CAkey "$CAkey" || { | ||
echo "Error: Failed to generate CA-signed certificate." | ||
exit 1 | ||
} | ||
fi | ||
else | ||
echo "Existing SSL certificate and key found. Using them." | ||
fi | ||
|
||
|
||
# Execute the main binary and pass all script arguments | ||
exec /bin/ssv-dkg "$@" |
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