#!/usr/bin/env bash set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" cleanup() { docker compose -f "$PROJECT_ROOT/docker-compose.yml" -f "$PROJECT_ROOT/docker-compose.tests.yml" down --remove-orphans || true } trap cleanup EXIT # AZ-505 AC-5: HTTP/2 via ALPN requires TLS on the API listener. The cert is # self-signed for dev/test only — gitignored under certs/ and regenerated on # demand. PFX is mounted into the API container as the Kestrel cert; the public # PEM is mounted into the integration-tests container's CA trust store so every # HttpClient transparently trusts it without per-test handler shims. ensure_dev_cert() { local certs_dir="$PROJECT_ROOT/certs" local pfx="$certs_dir/api.pfx" local crt="$certs_dir/api.crt" if [[ -f "$pfx" && -f "$crt" ]]; then echo "Step 0a: Dev cert present (./certs/api.pfx)" return 0 fi echo "Step 0a: Generating dev TLS cert (./certs/api.pfx + api.crt) for HTTP/2 ALPN (AZ-505 AC-5)" mkdir -p "$certs_dir" docker run --rm -v "$certs_dir:/work" -w /work alpine:3.20 sh -c ' set -e apk add --no-cache openssl >/dev/null cat > /tmp/openssl.cnf <