fix: include CA name in certificate generation for improved clarity
This commit is contained in:
@@ -1,15 +1,16 @@
|
|||||||
function make_ca() {
|
function make_ca() {
|
||||||
# Use the provided directory argument or default to AZURITE_DIR if not provided
|
# Use the provided directory argument or default to AZURITE_DIR if not provided
|
||||||
local CERT_DIR="$1"
|
local CERT_DIR="$1"
|
||||||
|
local CA_NAME="$2"
|
||||||
|
|
||||||
if [[ -z "$CERT_DIR" || ! -d "$CERT_DIR" ]]; then
|
if [[ -z "$CERT_DIR" || -z "$CA_NAME" || ! -d "$CERT_DIR" ]]; then
|
||||||
echo "ERROR: Certificate directory $CERT_DIR does not exist."
|
echo "ERROR: Certificate directory $CERT_DIR does not exist."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Generate CA certificate and key if they don't exist
|
# Generate CA certificate and key if they don't exist
|
||||||
if [[ ! -f "$CERT_DIR/ca_cert.pem" || ! -f "$CERT_DIR/ca_key.pem" ]]; then
|
if [[ ! -f "$CERT_DIR/ca_cert.pem" || ! -f "$CERT_DIR/ca_key.pem" ]]; then
|
||||||
echo "Generating CA certificate and key..."
|
echo "Generating CA certificate '$CA_NAME' and key..."
|
||||||
if ! openssl req \
|
if ! openssl req \
|
||||||
-x509 \
|
-x509 \
|
||||||
-newkey rsa:4096 \
|
-newkey rsa:4096 \
|
||||||
@@ -17,7 +18,7 @@ function make_ca() {
|
|||||||
-out "$CERT_DIR/ca_cert.pem" \
|
-out "$CERT_DIR/ca_cert.pem" \
|
||||||
-days 3650 \
|
-days 3650 \
|
||||||
-nodes \
|
-nodes \
|
||||||
-subj "/CN=Azurite CA" \
|
-subj "/CN=${CA_NAME}" \
|
||||||
-text \
|
-text \
|
||||||
-addext "basicConstraints=critical,CA:TRUE,pathlen:0"; then
|
-addext "basicConstraints=critical,CA:TRUE,pathlen:0"; then
|
||||||
echo "ERROR: Failed to generate CA certificate and key." >&2
|
echo "ERROR: Failed to generate CA certificate and key." >&2
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ while [[ $# -gt 0 ]]; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Ensure certificates are generated before starting Azurite or Caddy.
|
# Ensure certificates are generated before starting Azurite or Caddy.
|
||||||
if ! make_ca "$AZURITE_STORAGE"; then
|
if ! make_ca "$AZURITE_STORAGE" "Azurite CA $(date +%Y.%m)"; then
|
||||||
echo "Error: Failed to create CA certificate and key." >&2
|
echo "Error: Failed to create CA certificate and key." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user