Add signing certificates endpoint to attestations API
What does this MR do and why?
Adds GET /projects/:id/attestations/signing_certificates, which returns the unexpired certificate authority (CA) certificates of a project as PEM. LOCAL_CA attestation bundles have no Rekor entry, so cosign needs the project CA as the trust anchor (cosign trusted-root create, then verify-blob-attestation --trusted-root). Today the certificate is only reachable from a Rails console. glab attestation verify will use this endpoint, and users can download the certificates once for offline verification.
- Returns active and inactive certificates, so attestations signed before a future CA rotation stay verifiable. Expired certificates are left out: the driver only issues a leaf when the CA outlives it, so an expired CA has no valid leaves left.
- Exposes only
id,certificate,active,expires_at, andcreated_at. The private key is never exposed (the spec asserts it). - Same gates as the other attestation endpoints: the
slsa_provenance_statementfeature flag (404 when off),read_attestation, and granular token authorization. Markedroute_setting :lifecycle, :experiment. - Regenerates the OpenAPI v3 definition and the fine-grained token REST docs.
Stacked on !268753 (merged), which adds the not_expired scope and carries the query plan.
References
- https://gitlab.com/gitlab-org/gitlab/-/work_items/603915
- https://gitlab.com/groups/gitlab-org/-/work_items/22313
- !267389 (merged) (exposes
signing_method) - gitlab-org/cells/http-router!1521 (merged) (paired HTTP Router snapshot refresh;
cells-routes:router-in-syncpasses once it merges)
Screenshots or screen recordings
How to set up and validate locally
- Enable the flag for a project in the Rails console:
Feature.enable(:slsa_provenance_statement, Project.find(ID)) - Run a pipeline with
ATTEST_METHOD: LOCAL_CAso the project gets a CA, or use a project that already hasLOCAL_CAattestations. - Run
curl --request GET --header "PRIVATE-TOKEN: <token>" --url "http://gdk.test:3000/api/v4/projects/ID/attestations/signing_certificates". - Compare the returned
certificatewithSupplyChain::PostgresCaDriver.new(Project.find(ID)).ca_certificate.to_pemin the Rails console.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
