Overview

Every Prism organization has its own certificate authority. Any authenticated principal can get a certificate for its own identity: Prism generates the key pair, and puts the principal's canonical name in the subject and as a SAN. Callers cannot choose the subject.

Subject: CN=payments-api@service-accounts.payments.id.prism.example.com
Issuer:  CN=Acme Root CA, O=Acme
X509v3 Subject Alternative Name:
    email:payments-api@service-accounts.payments.id.prism.example.com

A server that trusts the organization CA therefore learns, from the client certificate alone, which Prism service account or user is calling. Service accounts can additionally get DNS names in their certificates, so the same certificate can serve TLS, but only for hostnames under domains the project has proven it owns.

  1. Issue a client certificate

    Logged in as the service account (any login method). Certificates last 30 days unless --validity-days says otherwise:

    prism --output json org issue-cert --validity-days 7 > cert.json
    jq -r .certificate_pem cert.json > client.pem
    jq -r .private_key_pem cert.json > client-key.pem && chmod 600 client-key.pem
    prism org ca > prism-ca.pem

    Add --group <canonical group name> to include one of the caller's groups as an extra SAN, e.g. email:operators@groups.payments.id.prism.example.com, so servers can authorize on team membership. A user with service_accounts.act_as can issue for a service account with --as-service-account.

  2. Verify clients on the server

    Trust only the organization CA for client certificates, then authorize on the SAN. With nginx:

    ssl_client_certificate /etc/prism/prism-ca.pem;
    ssl_verify_client      on;
    
    # Only the payments API may call this service
    map $ssl_client_s_dn $prism_caller_ok {
        "CN=payments-api@service-accounts.payments.id.prism.example.com" 1;
        default 0;
    }
    location / {
        if ($prism_caller_ok = 0) { return 403; }
        proxy_set_header X-Prism-Caller $ssl_client_s_dn;
        proxy_pass http://127.0.0.1:8080;
    }

    Test it:

    curl --cacert server-ca.pem --cert client.pem --key client-key.pem https://ledger.internal.example.com/
  3. Verify a domain for server certificates

    Hostnames in certificates must lie under a domain verified by DNS. A domain can be a subdomain of what you registered, so teams can own e.g. internal.example.com:

    prism projects domains create -p payments internal.example.com
    # challenge_record: _prism-challenge.internal.example.com
    # challenge_token:  prism-domain-verification=84144ce7-…
    
    # Publish the TXT record, then
    prism projects domains verify -p payments internal.example.com

    Prism re-checks verified domains hourly; if the record disappears, issuance for its hostnames stops.

  4. Allow a service account its hostnames

    Hostnames may be exact, or use Unix glob wildcards that match within a single DNS label (*.web.internal.example.com matches a.web… but not a.b.web…):

    prism service-accounts hostnames add -p payments ledger-api ledger.internal.example.com
    prism service-accounts hostnames add -p payments ledger-api 'ledger-[0-9].internal.example.com'
    prism service-accounts hostnames list -p payments ledger-api
  5. Issue a server certificate

    Logged in as ledger-api, request specific names with --hostname; without it, the certificate gets all of the account's hostnames that contain no wildcard:

    prism --output json org issue-cert --validity-days 30 \
      --hostname ledger.internal.example.com --hostname ledger-1.internal.example.com > server.json

    The certificate has the hostnames as DNS SANs alongside the service account's identity, so it serves both as the TLS server certificate and as the client certificate when ledger-api calls other services.

  6. Renew automatically

    Certificates are meant to be short-lived. Re-issue from a timer at half the lifetime, and reload the server. On EC2, prism-ec2-bootstrap already does this, see EC2 Host Identity and SSH Certificates.

    # /etc/cron.d/prism-cert — every day at 03:00
    0 3 * * * root /usr/local/bin/renew-prism-cert.sh && systemctl reload nginx

Auditing

Each issuance is logged as OrganizationsIssueCertificate, with the subject, validity and hostnames:

prism org audit --org acme
# … OrganizationsIssueCertificate allowed {"subject":"ledger-api@…","validity_days":30,"hostname_sans":["ledger.internal.example.com",…]}

Security considerations