- The device requests a single-use nonce from
/api/iot/devices/:id/attestation/challenge. - The device produces a
TPM2_Quoteover selected PCRs (with the nonce as qualifying data) and aTPM2_Certifybinding the CSR public key to a TPM-resident Attestation Key. - The device submits the full evidence bundle to
/api/iot/devices/:id/attest-and-provision, which consumes the nonce, evaluates the matchingattestation_policy, calls PKI Core’s/certificates/sign-attestedverifier, and returns a certificate on success or403 attestation_failedwith structured failures.
Attestation policies
Policies are the trust anchors — they declare which PCR values, PCR banks, EK manufacturers, and freshness constraints are acceptable for a given device type.List policies
GET /api/attestation/policies
Filter to policies scoped to a given device type. Omit for workspace-wide list.
Matches
iot_devices.deviceType. null = matches any type.Nested map:
{ "SHA256": { "0": "hex", "7": "hex", ... } }.Default
["SHA256"].Default
[0,1,2,3,4,7].e.g.
["Intel","Infineon","STMicro"]. Empty = any TPM vendor trusted root.Enforces
TPM2_Certify.Get a policy
GET /api/attestation/policies/:id
Returns 404 Policy not found if the ID doesn’t exist.
Create a policy
POST /api/attestation/policies
Body is validated against insertAttestationPolicySchema from @shared/schema. Returns 400 { "error": "Invalid policy", "details": {...} } on validation failure.
Update a policy
PATCH /api/attestation/policies/:id — partial update.
Delete a policy
DELETE /api/attestation/policies/:id — returns 204 No Content.
Nonce challenge
POST /api/iot/devices/:id/attestation/challenge
Mints a single-use random nonce (32 bytes hex-encoded) bound to a device. The nonce must be included in the subsequent TPM2_Quote as qualifyingData.
Device ID.
How long the nonce is valid.
Attest and provision
POST /api/iot/devices/:id/attest-and-provision
The load-bearing gated-issuance endpoint. Consumes the nonce, resolves the matching policy (explicit policyId wins, otherwise the first enabled policy for the device’s type), and hands the evidence bundle to PKI Core’s verifier. On success the issued certificate is returned and a passing attestation is recorded. On verifier failure the endpoint returns 403 with structured failure reasons and stores a failing attestation with trustScore=0.
Target CA (typically the internal device-issuing intermediate).
PKI Core template, e.g.
iot_device.PEM-encoded CSR.
Force evaluation against a specific policy. Otherwise the first enabled policy matching
device.deviceType is used.400 failure modes: nonce_not_found, nonce_already_used, nonce_expired, nonce_device_mismatch, or missing required fields (caId, templateId, csr, evidence.nonce and evidence.quoteBlob are required).
Non-attested device attestation records
For workflows that only want to record an attestation outcome without gating issuance:GET /api/iot/devices/:id/attestations— history for a devicePOST /api/iot/devices/:id/attest— record an arbitrary attestationPOST /api/iot/devices/:id/attest-tpm— record a TPM quote (no verifier gating)
See also
- Certificates — non-attested issuance path
- Agents — how field agents fetch nonces on behalf of devices
- Authentication — session/API-key requirements