Prerequisites
- An admin API key with
containers.createandcontainers.read, exported asTINFOIL_ADMIN_KEY. - Your image pinned by
@sha256:digest. For a private image, set registry credentials first. - Go 1.27.4 or later.
Set up a module
Write the config
Save this astinfoil-config.yml next to your program, with your image in place of the demo image:
tinfoil-config.yml
cvm-version to the SHA-256 of the runtime manifest, which you can compute yourself:
PUBLIC_KEY parameterizes the image with your public key; replace the demo key with your own. Anyone can run the same image digest with a different key, so the key in the config is what makes the container yours.
include-config-in-attestation puts the config itself into the attestation so the client can read it. Without it, the config stays out of the attestation and a client can only check it against bytes it already holds. See the configuration reference for the other fields.
Deploy and verify
main.go
- Deploy.
deploysends the config inline (source: local) and polls the container until it isrunning. Tinfoil stores the config in its canonical JSON form, which is the form the enclave measures. - Verify the attestation.
tinfoil.NewEnclaveHTTPClientfetches a fresh attestation from the container’s domain and checks the hardware report, the runtime thatcvm-versionpins, and that the config in the attestation is the one that was measured.AuthorizedByhands that config to your function instead of requiring a registry endorsement. - Check the shape.
requireShaperejects the enclave unless its config runs only your image, by digest, with your public key as its only environment variable and no administrator access throughcvm_adminor direct admin SSH. The key must be a literal inenv, not a name filled in at deploy time or a secret, since neither is in the attestation. Add checks for anything else you rely on, such as networks.
NewEnclaveHTTPClient returns an error and the program sends nothing. On success, enclave is an *http.Client whose requests reach only the verified enclave, and it verifies again when its verification expires.