Repository navigation
feat(pki): HSM-backed sub-CA - CSR generation and oracle signing of certificates, CRLs and OCSP - #1328
Open
Manuthor wants to merge 8 commits into
Open
feat(pki): HSM-backed sub-CA - CSR generation and oracle signing of certificates, CRLs and OCSP#1328Manuthor wants to merge 8 commits into
Manuthor wants to merge 8 commits into
Conversation
…A keys - add POST /certificates/csr: PKCS#10 CSR signed by the HSM through the crypto oracle (Sign permission only, non-extractable key) - Certify/ReCertify, GenerateCrl and the OCSP responder sign HSM CA keys through the oracle (RSA, EC, Ed25519/Ed448 non-FIPS) and verify the signature - CrlRequester: server-triggered CRL regeneration reads the issuer certificate directly and authorizes the key as the certificate owner - self-signed HSM public key keeps its private key link - fix OCSP issuer hash check for sub-CAs - add _serial=<HEX> certificate tag, backfilled once at startup on all backends - ADR, use-case doc and changelog
Generate a PKCS#10 CSR for a private key held by the KMS through POST /certificates/csr; HSM keys sign inside the HSM.
Generate a PKCS#10 CSR for a KMS-held private key (HSM keys sign inside the HSM), with en, fr and zh-CN translations and a Playwright spec. Includes the prettier reformatting of ui/src/utils/utils.ts required by the format hook.
ctutils 0.4.2 (via crypto-bigint -> k256 -> cosmian_kms_crypto) may compile const-fn mask generation to a branch; fixed in 0.4.4. Lock-only bump, new cargo-vet exemption for 0.4.5 (the 0.4.2 one is pruned).
POST /certificates/csr signed with Deactivated or not-yet-active keys, while Sign and Certify refuse them. Also correct the changelog (EST is unaffected, Ed448 supported), the openapi error codes and a revoke.rs comment.
…icKeyLink Adversarial review: the user-settable PublicKeyLink of the private key was followed without an access check and leaked another user's object attributes in the error; a key without the Sign usage could still sign; KEM keys (X25519, ML-KEM) returned a 5xx. Database keys now derive the public key from the private key, HSM keys use <id>_pk.
…tion Other OpenSSL signing failures are server faults and propagate unchanged. Adds the X25519 regression test.
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Lets an online KMS run a delegated (sub) CA whose private key never leaves the HSM, with an offline root signing the sub-CA CSR using its own HSM key. Full rationale:
documentation/adr/2026-10-23-hsm-backed-sub-ca-csr-and-oracle-signing.md.Server
POST /certificates/csr. The CSR is signed by the HSM through the crypto oracle and needs only theSignpermission on the key. An extractable HSM key is refused.Certify/ReCertify,GenerateCrland the OCSP responder sign HSM CA keys through the crypto oracle. The structure is built with a placeholder key, re-signed by the HSM, and verified against the real public key before use.CrlRequester::{User, Server}. Post-Revoke and cron regeneration reads the issuer certificate directly, and the signing key is authorized as the issuer certificate's owner (never the caller). Forhsm::keys that owner still needs a grant or HSM-admin rights (documented as NEG-002).<sk>_pkderives<sk>as the private-key link, for both issuer lookup and the certificate'sPrivateKeyLink.verify_issuer_hashes_match_caansweredunauthorizedfor every non-self-signed CA, because it hashed the CA's issuer name. It now hashes the CA's own subject, so OCSP works for sub-CAs (HSM or not)._serial=<HEX>tag: added to every stored certificate (Certify, ReCertify, Import, Register, PKCS#12). Existing certificates are backfilled once at startup on SQLite, PostgreSQL, MySQL/MariaDB and Redis-Findex, gated by a marker. The SQL inserts are conflict-tolerant so multi-node starts are safe.NotSupportedfor a sensitive HSM CA key; EST works.CLI
ckms certificates generate-csr(+ regenerated CLI docs).UI
ui/src/utils/utils.tsrequired by the format hook.Docs
use_cases/pki-sub-ca-csr.md, changelog entry, log reference.Behaviour changes
hsm::issuer key (including non-sensitive ones that used to be exported) now signs through the oracle for Certify, ReCertify, CRL and OCSP. HSM CA keys other than RSA/EC/Ed25519/Ed448 are rejected withNotSupported; a P-384 HSM CA signsecdsa-with-SHA256._serial=tag write on the first start after upgrade.Verification
oracle_signing,sub_ca_tests,crl_tests,revoke_tests,enrollment_tests, certify, OCSP,test_validate, plus a crypto unit test for the sub-CA OCSP hash fix.test_hsm_allon SoftHSM2 (FIPS and non-FIPS): HSM root, sub-CA CSR, leaf, CRL, Ed25519 sub-CA, and OCSP good/revoked signed by the HSM.test_db_postgresql(+ multihost, failover),test_db_mysql,test_db_redis_with_findex.Not covered
pgsql::tests::test_db_postgresql_tls_sslmode_matrixwas not run successfully (needs a TLS server).