Skip to content
Merged
Show file tree
Hide file tree
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
15 changes: 9 additions & 6 deletions custom-domain/dstack-ingress/scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,17 @@ set_caa_record() {
echo "Skipping CAA record setup"
return
fi

local ACCOUNT_URI
find /etc/letsencrypt/accounts -name regr.json
path="/etc/letsencrypt/accounts/acme-v02.api.letsencrypt.org/directory/*/regr.json"
if [ "$CERTBOT_STAGING" == "true" ]; then
path="${path/acme-v02/acme-staging-v02}"
local account_file

if ! account_file=$(get_letsencrypt_account_file); then
echo "Warning: Cannot set CAA record - account file not found"
echo "This is not critical - certificates can still be issued without CAA records"
return
fi
ACCOUNT_URI=$(jq -j '.uri' $path)

ACCOUNT_URI=$(jq -j '.uri' "$account_file")
echo "Adding CAA record for $domain, accounturi=$ACCOUNT_URI"
dnsman.py set_caa \
--domain "$domain" \
Expand All @@ -217,7 +221,6 @@ set_caa_record() {
echo "Warning: Failed to set CAA record for $domain"
echo "This is not critical - certificates can still be issued without CAA records"
echo "Consider disabling CAA records by setting SET_CAA=false if this continues to fail"
# Don't exit - CAA records are optional for certificate generation
fi
}

Expand Down
26 changes: 26 additions & 0 deletions custom-domain/dstack-ingress/scripts/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,29 @@ sanitize_proxy_timeout() {
echo ""
fi
}

get_letsencrypt_account_path() {
local base_path="/etc/letsencrypt/accounts"
local api_endpoint="acme-v02.api.letsencrypt.org"

if [[ "$CERTBOT_STAGING" == "true" ]]; then
api_endpoint="acme-staging-v02.api.letsencrypt.org"
fi

echo "${base_path}/${api_endpoint}/directory/*/regr.json"
}

get_letsencrypt_account_file() {
local account_pattern
account_pattern=$(get_letsencrypt_account_path)

local account_files
account_files=( $account_pattern )

if [[ ! -f "${account_files[0]}" ]]; then
echo "Error: Let's Encrypt account file not found at $account_pattern" >&2
return 1
fi

echo "${account_files[0]}"
}
11 changes: 6 additions & 5 deletions custom-domain/dstack-ingress/scripts/generate-evidences.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

set -e

path="/etc/letsencrypt/accounts/acme-v02.api.letsencrypt.org/directory/*/regr.json"
if [ "$CERTBOT_STAGING" == "true" ]; then
path="${path/acme-v02/acme-staging-v02}"
source "/scripts/functions.sh"

if ! ACME_ACCOUNT_FILE=$(get_letsencrypt_account_file); then
echo "Error: Cannot generate evidences without Let's Encrypt account file"
exit 1
fi
ACME_ACCOUNT_FILE=$(ls $path)

mkdir -p /evidences
cd /evidences || exit
cp ${ACME_ACCOUNT_FILE} acme-account.json
cp "${ACME_ACCOUNT_FILE}" acme-account.json

# Get all domains and copy their certificates
all_domains=$(get-all-domains.sh)
Expand Down
Loading