Workload API
The two calls a confidential workload makes to prove itself and get a secret.
A workload gets a secret in two calls: it asks for a nonce, then sends the nonce back signed, with its attestation manifest. Neither call takes a password or token. The signature and the instance’s policies are the only authorization.
All requests are JSON (Content-Type: application/json) over HTTPS.
Example
From inside a CRT container or a Confidential Containers pod, with the EQTY Notary signing:
GUARDIAN=https://guardian.example.com
NOTARY=http://docker.eqtylab.internal:8066 # in a CoCo pod: http://localhost:8066
HANDLE=1/hf-token # <instance id>/<handle>
# 1. A nonce for this secret, valid for 5 minutes.
NONCE=$(curl -sf "$GUARDIAN/api/request-nonce" \
-H 'Content-Type: application/json' \
-d "{\"secret_handle\": \"$HANDLE\"}" | jq -r .nonce)
# 2. The notary's manifest, and its signature over the nonce.
curl -sf "$NOTARY/v1/did_registration" > manifest.json
SIG_HEX=$(curl -sf -X POST "$NOTARY/v1/sign" \
-d "data=$(printf %s "$NONCE" | xxd -p -c0)" | jq -r .signature)
SIG_B64=$(printf %s "$SIG_HEX" | xxd -r -p | base64 -w0)
# 3. Prove it, and get the secret.
jq -n --arg h "$HANDLE" --arg n "$NONCE" --arg s "$SIG_B64" --slurpfile m manifest.json \
'{secret_handle: $h, nonce: $n, signed_nonce: $s, attestation_data: $m[0]}' |
curl -sf "$GUARDIAN/api/attest" -H 'Content-Type: application/json' -d @- |
jq -r 'if .result == "pass" then .secret else error("refused, reference \(.reference)") end'The notary signs with a key its manifest binds to the TEE quote. Key Guardian needs manifests in the identity-credential format, from vcomp-notary 0.0.7 or later.
POST /api/request-nonce
{ "secret_handle": "1/hf-token" }secret_handle is <instance id>/<handle>, as shown on the instance’s Secrets page. The reply:
{ "status": "success", "nonce": "9f2c…", "expires_in": 300 }The nonce works once, for 300 seconds. An unknown handle still gets a nonce, so the reply never reveals whether a secret exists.
POST /api/attest
{
"secret_handle": "1/hf-token",
"nonce": "9f2c…",
"signed_nonce": "MEUCIQ…",
"attestation_data": { "version": "…", "contexts": {}, "statements": [], "blobs": {} }
}| Field | |
|---|---|
secret_handle | Required. The handle the nonce was issued for. |
nonce | Required. From /api/request-nonce. |
signed_nonce | Required. Base64 of an ECDSA P-256 / SHA-256 signature over the nonce’s UTF-8 bytes, raw r‖s or DER. |
attestation_data | Required. The attestation manifest, up to 10 MiB. |
signing_did | Optional. The did:key that signed, to skip trying the others. It grants nothing. |
extra | Optional, per secret type. A passkey secret needs {"challenge": "<the site's login challenge>"}. |
Key Guardian checks the nonce, checks that a P-256 did:key declared in the manifest signed it,
uses up the nonce, evaluates the instance’s policies, and logs the attempt.
Responses
Passed. The secret is in secret:
{ "status": "success", "result": "pass", "secret": "hf_aXv93kQ2…" }An attestation token secret returns the JWT, or the claims as JSON. A passkey secret returns the WebAuthn assertion as JSON.
Refused. Whatever the reason, the workload gets only this:
{ "status": "success", "result": "fail", "reference": "0575b3e1" }result is error instead if a policy couldn’t be evaluated. Look up the reference in the
attestation logs to see why.
Expired nonce. The one failure a workload can act on. It comes with HTTP 400; request a new
nonce and try again.
{ "status": "error", "message": "nonce is not valid - request a new one", "reference": "…" }Status codes
| Code | When |
|---|---|
200 | The request was evaluated. Check result. |
400 | A required field is missing, the body isn’t JSON, or the nonce has expired. |
413 | The request is over 11 MiB. |
429 | Over 120 requests a minute from this client. Retry after 60 seconds. |
GET /setup/jwks.json
The Guardian root key as a JSON Web Key Set, for verifying attestation token JWTs. Public.
{ "keys": [{ "kty": "EC", "crv": "P-256", "kid": "…", "alg": "ES256", "x": "…", "y": "…" }] }alg is ES256 for a P-256 root and ES256K for secp256k1.
Good practice
- Keep the secret in memory. Don’t write it to disk or logs.
- Request the secret at start-up, and exit on
fail. A restart gets a fresh attempt and a fresh log entry. - Call Key Guardian only over HTTPS, and check its certificate.