feat: enhance certificate generation functions and add make_account_cert for streamlined server cert creation
This commit is contained in:
@@ -5,6 +5,23 @@ set -e
|
||||
# Include certificate generation functions.
|
||||
. /app/cert-functions.sh
|
||||
|
||||
function make_account_cert() {
|
||||
local CERT_DIR="$1"
|
||||
local ACCOUNT_NAME="${2:-devstoreaccount1}"
|
||||
# -addext "subjectAltName=DNS:${ACCOUNT_NAME}.blob.core.windows.net,DNS:${ACCOUNT_NAME}.queue.core.windows.net,DNS:${ACCOUNT_NAME}.table.core.windows.net,DNS:${ACCOUNT_NAME}.blob.localhost,DNS:${ACCOUNT_NAME}.queue.localhost,DNS:${ACCOUNT_NAME}.table.localhost,DNS:localhost,IP:127.0.0.1"
|
||||
|
||||
make_server_cert "$CERT_DIR" "${ACCOUNT_NAME}.blob.core.windows.net" \
|
||||
"${ACCOUNT_NAME}.queue.core.windows.net" \
|
||||
"${ACCOUNT_NAME}.table.core.windows.net" \
|
||||
"${ACCOUNT_NAME}.blob.localhost" \
|
||||
"${ACCOUNT_NAME}.queue.localhost" \
|
||||
"${ACCOUNT_NAME}.table.localhost" \
|
||||
"localhost" \
|
||||
"127.0.0.1"
|
||||
|
||||
return $?
|
||||
}
|
||||
|
||||
# Setup default storage location, account name and accounts file path.
|
||||
AZURITE_STORAGE="${AZURITE_STORAGE:-/storage}"
|
||||
|
||||
@@ -61,20 +78,21 @@ if ! make_ca "$AZURITE_STORAGE"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! make_server_cert "$ACCOUNT_NAME" "$AZURITE_STORAGE"; then
|
||||
if ! make_account_cert "$AZURITE_STORAGE" "$ACCOUNT_NAME"; then
|
||||
echo "Error: Failed to create server certificate and key." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Generate a Caddyfile configuration based on the account name and storage directory.
|
||||
sed -E "s/__ACCOUNT_NAME__/${ACCOUNT_NAME}/g; s|__AZURITE_STORAGE__|${AZURITE_STORAGE}|g" /app/Caddyfile.example > "$AZURITE_STORAGE/Caddyfile"
|
||||
|
||||
if [[ -z "$NO_CADDY" ]]; then
|
||||
# Generate a Caddyfile configuration based on the account name and storage directory.
|
||||
sed -E "s/__ACCOUNT_NAME__/${ACCOUNT_NAME}/g; s|__AZURITE_STORAGE__|${AZURITE_STORAGE}|g" /app/Caddyfile.example > "$AZURITE_STORAGE/Caddyfile"
|
||||
# Start Caddy in the background to handle HTTPS requests and route them to Azurite.
|
||||
caddy start --config "$AZURITE_STORAGE/Caddyfile" # Use start not run, start does not block the shell process.
|
||||
HOST_ARGS=("--blobHost" "127.0.0.1" "--queueHost" "127.0.0.1" "--tableHost" "127.0.0.1")
|
||||
else
|
||||
HOST_ARGS=("--blobHost" "0.0.0.0" "--queueHost" "0.0.0.0" "--tableHost" "0.0.0.0")
|
||||
fi
|
||||
|
||||
HOST_ARGS=("--blobHost" "127.0.0.1" "--queueHost" "127.0.0.1" "--tableHost" "127.0.0.1")
|
||||
PORT_ARGS=("--blobPort" "10000" "--queuePort" "10001" "--tablePort" "10002")
|
||||
|
||||
# Start Azurite with the appropriate arguments based on the configuration.
|
||||
|
||||
Reference in New Issue
Block a user