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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ TELEMETRY_HOST_SECURE_RADS=telemetry.sr.secure-rads.org
COST_HOST_RADS=cost.r.secure-rads.org
COST_HOST_SECURE_RADS=cost.sr.secure-rads.org
PDM_HOST=pdm.sr.secure-rads.org
PDM_MTLS_HOST=pdm-mtls.sr.secure-rads.org
KMS_HOST=kms.sr.secure-rads.org
PDM_HOST_RADS=pdm.r.secure-rads.org
REGISTRY_HOST_RADS=registry.r.secure-rads.org
Expand Down
22 changes: 15 additions & 7 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
COST_HOST_RADS: ${{ vars.COST_HOST_RADS }}
COST_HOST_SECURE_RADS: ${{ vars.COST_HOST_SECURE_RADS }}
PDM_HOST: ${{ vars.PDM_HOST }}
PDM_MTLS_HOST: ${{ vars.PDM_MTLS_HOST || 'pdm-mtls.sr.secure-rads.org' }}
PDM_HOST_RADS: ${{ vars.PDM_HOST_RADS }}
REGISTRY_HOST_RADS: ${{ vars.REGISTRY_HOST_RADS }}
EXECUTION_HOST_RADS: ${{ vars.EXECUTION_HOST_RADS }}
Expand All @@ -48,6 +49,7 @@ jobs:
CLOUDFLARE_ZONE: ${{ vars.CLOUDFLARE_ZONE }}
CLOUDFLARE_EMAIL: ${{ secrets.CLOUDFLARE_EMAIL }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
SERVERLESS_ACCESS_KEY: ${{ secrets.SERVERLESS_ACCESS_KEY }}
steps:
- uses: actions/checkout@v5

Expand All @@ -73,6 +75,19 @@ jobs:
printf '%s' "$REGISTRY_TLS_KEY_B64" | base64 -d >secure/csav/registry-service/tls/client.key
chmod 600 secure/csav/registry-service/tls/client.crt secure/csav/registry-service/tls/client.key

- name: Write PDM client trust material
env:
PDM_CLIENT_CERT_B64: ${{ secrets.PDM_CLIENT_CERT_B64 }}
PDM_CLIENT_KEY_B64: ${{ secrets.PDM_CLIENT_KEY_B64 }}
run: |
set -euo pipefail
[ -n "$PDM_CLIENT_CERT_B64" ] || { echo "PDM_CLIENT_CERT_B64 is not set" >&2; exit 1; }
[ -n "$PDM_CLIENT_KEY_B64" ] || { echo "PDM_CLIENT_KEY_B64 is not set" >&2; exit 1; }
mkdir -p secure/pdm-service/tls
printf '%s' "$PDM_CLIENT_CERT_B64" | base64 -d >secure/pdm-service/tls/client.crt
printf '%s' "$PDM_CLIENT_KEY_B64" | base64 -d >secure/pdm-service/tls/client.key
chmod 600 secure/pdm-service/tls/client.crt secure/pdm-service/tls/client.key

- name: Write CSAV SSH key
env:
CSAV_SSH_KEY_B64: ${{ secrets.CSAV_SSH_KEY_B64 }}
Expand All @@ -83,12 +98,5 @@ jobs:
printf '%s' "$CSAV_SSH_KEY_B64" | base64 -d >.ssh/csav-key.pem
chmod 400 .ssh/csav-key.pem

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ vars.GHCR_USER || github.repository_owner }}
password: ${{ secrets.GHCR_TOKEN }}

- name: Deploy
run: scripts/deploy.sh deploy all
10 changes: 6 additions & 4 deletions docs/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,22 @@ certificates are looked up by hostname in ACM.
| `LOG_HOST_RADS`, `LOG_HOST_SECURE_RADS` | log-service hostnames |
| `TELEMETRY_HOST_RADS`, `TELEMETRY_HOST_SECURE_RADS` | telemetry-service hostnames |
| `COST_HOST_RADS`, `COST_HOST_SECURE_RADS` | cost-service hostnames |
| `PDM_HOST`, `PDM_HOST_RADS` | PDM hostnames |
| `PDM_HOST`, `PDM_HOST_RADS`, `PDM_MTLS_HOST` | PDM hostnames; `PDM_MTLS_HOST` is the mTLS-only count endpoint |
| `KMS_HOST`, `VERIFIER_HOST`, `VERIFIER_ATTEST_HOST`, `VERIFIER_URL` | secure service hostnames |
| `REGISTRY_HOST_RADS`, `EXECUTION_HOST_RADS` | rads registry and execution API hostnames |
| `VERIFIER_JWKS_URL`, `VERIFIER_JWKS_PUBKEY_SHA256` | JWKS endpoint and pin used by pdm/log/kms |
| `VERIFIER_PUBKEY_SHA256`, `VERIFIER_HOST_PUBKEY_SHA256`, `PDM_HOST_PUBKEY_SHA256`, `KMS_HOST_PUBKEY_SHA256`, `LOG_HOST_PUBKEY_SHA256`, `TELEMETRY_HOST_PUBKEY_SHA256` | TLS pins baked into the registry image |
| `GHCR_USER` | account that can pull `ghcr.io/secure-rads/nsjail-docker` |
| `CLOUDFLARE_ZONE` | Cloudflare zone |

## Repository secrets

| Secret | Purpose |
| --- | --- |
| `GHCR_TOKEN` | pull the private nsjail base image |
| `REGISTRY_TLS_CERT_B64`, `REGISTRY_TLS_KEY_B64` | base64 of the existing `secure/csav/registry-service/tls/client.{crt,key}` |
| `CSAV_SSH_KEY_B64` | base64 of `.ssh/csav-key.pem`, used to ship the registry image |
| `PDM_CLIENT_CERT_B64`, `PDM_CLIENT_KEY_B64` | base64 of `secure/pdm-service/tls/client.{crt,key}`; the execution-service -> PDM count client identity |
| `CLOUDFLARE_EMAIL`, `CLOUDFLARE_API_TOKEN` | Cloudflare API credentials |
| `SERVERLESS_ACCESS_KEY` | Serverless Framework v4 license key; required because unattended runs cannot sign in |

`REGISTRY_TLS_CERT_B64` must be the same client certificate the verifier truststore was created
from. Generating a new certificate rotates the trust material and breaks registration until the
Expand All @@ -116,7 +116,7 @@ The secure registry-service image builds on a 2 vCPU Blacksmith arm64 runner, so
`--platform linux/arm64` is native and needs no QEMU. That runner holds one job at a time here, so the
image build gets the full runner. The `eif-build-base` cargo step is the heavy part; bump to
`blacksmith-4vcpu-ubuntu-2404-arm` if that build dominates. It builds `sce-unit-base` and
`eif-build-base` first, pulls the private `ghcr.io/secure-rads/nsjail-docker` base, ships the tarball
`eif-build-base` first, pulls the public `ghcr.io/secure-rads/nsjail-docker` base, ships the tarball
over SSH, and restarts the compose service on the CSAV host.

## Known gaps
Expand All @@ -127,3 +127,5 @@ over SSH, and restarts the compose service on the CSAV host.
- The verifier JWT signing key must already exist at the SSM path the service reads. See
`docs/getting-started.md`.
- The CSAV key pair and the CSAV instance must already exist before the registry image ships.
- A DNS-only CNAME for `PDM_MTLS_HOST` must point at the `PdmMtlsRegionalDomainName` output of
`secure-rads-pdm-service-dev`. The deploy does not manage Cloudflare DNS.
28 changes: 22 additions & 6 deletions scripts/lib/units.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,31 @@ unit_secure_verifier_service() {
}

unit_secure_pdm_service() {
need PDM_HOST LOG_HOST_SECURE_RADS COST_HOST_SECURE_RADS VERIFIER_JWKS_URL VERIFIER_JWKS_PUBKEY_SHA256
local arn
need PDM_HOST PDM_MTLS_HOST LOG_HOST_SECURE_RADS COST_HOST_SECURE_RADS VERIFIER_JWKS_URL VERIFIER_JWKS_PUBKEY_SHA256
local arn mtls_arn truststore version
arn=$(cert_for "$PDM_HOST")
mtls_arn=$(cert_for "$PDM_MTLS_HOST")
truststore=secure/pdm-service/tls/client.crt
[ -f "$truststore" ] || run make -C secure/pdm-service gen-client-cert
run make -C secure/pdm-service store-client-cert
sls secure/pdm-service \
--param="region=$region" \
--param="domainName=$PDM_HOST" \
--param="certificateArn=$arn"
--param="certificateArn=$arn" \
--param="mtlsDomainName=$PDM_MTLS_HOST" \
--param="mtlsCertificateArn=$mtls_arn"
version=$(aws s3api put-object \
--bucket "$(stack_output secure-rads-pdm-service-dev PdmTruststoreBucketName)" \
--key truststore.pem \
--body "$truststore" \
--query VersionId --output text)
sls secure/pdm-service \
--param="region=$region" \
--param="domainName=$PDM_HOST" \
--param="certificateArn=$arn" \
--param="mtlsDomainName=$PDM_MTLS_HOST" \
--param="mtlsCertificateArn=$mtls_arn" \
--param="truststoreVersionId=$version"
}

unit_secure_kms_service() {
Expand Down Expand Up @@ -223,15 +241,14 @@ unit_rads_execution_service() {
need EXECUTION_HOST_RADS PDM_HOST_RADS RADS_EXECUTOR_AMI_ID AVAILABILITY_ZONE \
LOG_HOST_RADS TELEMETRY_HOST_RADS COST_HOST_RADS
local arn images_bucket algorithm_table run_results_table run_results_queue_url \
run_results_queue_arn pdm_table vpc
run_results_queue_arn vpc
arn=$(cert_for "$EXECUTION_HOST_RADS")
vpc=$(default_vpc)
images_bucket=$(stack_output rads-registry-service-dev ImagesBucketName)
algorithm_table=$(stack_output rads-registry-service-dev AlgorithmsTableName)
run_results_table=$(stack_output rads-result-consumer-dev RunResultsTableName)
run_results_queue_url=$(stack_output rads-result-consumer-dev RunResultsQueueUrl)
run_results_queue_arn=$(stack_output rads-result-consumer-dev RunResultsQueueArn)
pdm_table=$(stack_output rads-pdm-service-dev PersonalDataTableName)
sls rads/sce/execution-service \
--param="region=$region" \
--param="vpcId=$vpc" \
Expand All @@ -241,7 +258,6 @@ unit_rads_execution_service() {
--param="runResultsQueueUrl=$run_results_queue_url" \
--param="runResultsQueueArn=$run_results_queue_arn" \
--param="pdmUrl=https://$PDM_HOST_RADS" \
--param="pdmTable=$pdm_table" \
--param="domainName=$EXECUTION_HOST_RADS" \
--param="certificateArn=$arn"
}
Expand Down
2 changes: 1 addition & 1 deletion secure/pdm-service/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ resources:
ApiId: !Ref CountHttpApi
RouteKey: GET /count
AuthorizationType: NONE
Target: !Join ["integrations/", !Ref CountIntegration]
Target: !Sub "integrations/${CountIntegration}"

CountLambdaPermission:
Type: AWS::Lambda::Permission
Expand Down