Skip to main content

sign_csr

Function sign_csr 

pub fn sign_csr(
    ca_cert_pem: &str,
    ca_key_pem: &str,
    device_id: &str,
    csr_pem: &str,
) -> Result<IssuedLeaf>
Expand description

Sign a client-submitted CSR into a clientAuth-only leaf bound to device_id.

SECURITY (threat A7 - CSR field injection): the CA reads only the CSR’s public key. [rcgen::CertificateSigningRequestParams::from_pem] verifies the CSR self-signature and rejects unsupported extensions; we then discard every CSR-requested field by replacing the parsed params wholesale with the daemon’s own client profile (client_params: subject CN = device_id, clientAuth-only EKU, digitalSignature KU, CA:FALSE, notBefore backdated). A requester therefore cannot inject a subject, SAN, EKU, or basic-constraints into the issued certificate. The keypair stays on the device; no private key is returned.