Help us shape the future of Go! Take the 2026 Go Developer Survey

go-pki-cmp

module
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: Apache-2.0

README

go-pki-cmp

GitHub Release Go Reference License Tests Integration Supply chain OpenSSF Scorecard

Go library for the Certificate Management Protocol (CMP). Its core encodes, parses, protects and verifies CMP and CRMF messages. On top of it, the client package enrolls, updates and revokes certificates and the server package serves the same operations to CMP clients as an http.Handler in front of a CA. cmp-issuer, a cert-manager external issuer, is built on this library.

Contents

Install

go get github.com/misiektoja/go-pki-cmp

Requires Go 1.27.3 or newer. Releases up to v0.3.2 use the module path github.com/misiektoja/go-pkicmp-ng.

Package Content
pkicmp CMP and CRMF types with parsing, serialization and MAC or signature protection
client Enrollment, key update, revocation and support messages with response verification, certificate confirmation and polling that can resume in a later process
server An http.Handler that authenticates clients, tracks transactions and applies policy in front of your CA
cms EnvelopedData and EncryptedValue for proof of possession by decryption and centrally generated keys

Scope

Standard Coverage
RFC 9810 (obsoletes RFC 4210 and RFC 9480) CMP version 2 and version 3
RFC 9483 Lightweight CMP Profile
RFC 4211 Certificate Request Message Format (CRMF)
RFC 9811 (obsoletes RFC 6712) HTTP transfer for CMP

Supported messages are ir, cr, kur, p10cr, rr, certConf, pollReq, genm and nested with their responses. General messages carry the RFC 9483 support requests for CA certificates, a root CA update, a certificate request template and CRL updates.

Post-quantum keys: ML-DSA-44, ML-DSA-65, ML-DSA-87, the twelve SLH-DSA parameter sets and composite ML-DSA keys can enroll and sign CMP messages. ML-KEM-768 and ML-KEM-1024 keys, which cannot sign, prove possession by decryption.

Central key generation: a client can ask the CA to generate its key pair and receive the private key signed and encrypted for it (RFC 9483 section 4.1.6).

RFC 4210 peers work with the defaults. Options accept deployed clients that break RFC 9483 rules.

Key recovery, cross-certification and announcements are not implemented.

The support matrix and known limitations give the details.

Getting started

Enroll a certificate with a shared secret:

key, _ := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
creds, _ := pkicmp.NewMACCredentials([]byte("my-shared-secret"))

c := client.NewClient("http://localhost:8080/cmp")
result, err := c.SendIR(context.Background(), key, creds,
	client.WithSenderKID([]byte("my-device")),
	client.WithTemplateSubject(pkix.Name{CommonName: "my-device"}),
)

Serve CMP in front of your CA, which implements server.CA and the credential lookups:

srv := server.NewCAServer(myCA,
	server.LightweightPolicy(),
	server.WithSigner(caKey, caCert),
	server.WithSecretLookup(myCA),
	server.WithCertificateLookup(myCA),
)
if err := srv.Err(); err != nil {
	log.Fatal(err)
}
http.Handle("/cmp", srv)

examples holds a mock CA and a client that enrolls, updates and revokes a certificate against it. Run them in two terminals:

go run ./examples/mockserver/cmd
go run ./examples/mockclient/cmd

Getting started walks through both programs and names what to replace before production.

Interoperability

CI runs the library against EJBCA, OpenSSL 3.5 and 4.0 in both directions, a hosted Nokia NCM instance and the Siemens CMP test suite. Local tests also run the Insta Certifier 10 cmpclient and the Insta Certifier 7 ssh-cmpclient against the server. Both clients are proprietary, so CI does not run them.

Tested implementations lists the scenarios and the server options each client needs.

Documentation

Full documentation is at misiektoja.github.io/go-pki-cmp.

The package documentation on pkg.go.dev describes every exported type and option. RELEASE_NOTES.md records the changes in each release.

Credits

This project began as a fork of tsaarni/go-pkicmp by Tero Saarni (@tsaarni). Its package layout, ASN.1 types and client and server design come from that project. Early hardening changes were submitted in tsaarni/go-pkicmp#3. This fork is maintained separately. NOTICE records the attribution.

Support and contributing

SUPPORT.md says where to ask a question or report a bug. Report vulnerabilities privately as SECURITY.md describes. The Contributing Guide lists the development checks.

License

Apache License 2.0. See LICENSE and NOTICE. DEPENDENCIES.md lists third-party dependencies and their licenses.

Directories

Path Synopsis
Package client provides a Certificate Management Protocol (CMP) client for requesting X.509 certificates from a CA over HTTP.
Package client provides a Certificate Management Protocol (CMP) client for requesting X.509 certificates from a CA over HTTP.
Package cms encrypts and decrypts CMS EnvelopedData (RFC 5652 §6) for the CMP operations that need it: the encrypted certificate and the challenge-response proofs of possession (RFC 9810 §5.2.8.3) and the private key that central key generation returns (RFC 9483 §4.1.6).
Package cms encrypts and decrypts CMS EnvelopedData (RFC 5652 §6) for the CMP operations that need it: the encrypted certificate and the challenge-response proofs of possession (RFC 9810 §5.2.8.3) and the private key that central key generation returns (RFC 9483 §4.1.6).
examples
mockclient
Package mockclient provides reusable enrollment and revocation helpers built on top of the client and pkicmp packages.
Package mockclient provides reusable enrollment and revocation helpers built on top of the client and pkicmp packages.
mockclient/cmd command
Command mockclient is a minimal CMP client for testing.
Command mockclient is a minimal CMP client for testing.
mockserver
Package mockserver demonstrates how to implement the server.CA interface to build a CMP certificate authority server.
Package mockserver demonstrates how to implement the server.CA interface to build a CMP certificate authority server.
mockserver/cmd command
Command mockserver is a minimal CMP server for testing.
Command mockserver is a minimal CMP server for testing.
internal
certpath
Package certpath verifies certification paths that contain composite ML-DSA or SLH-DSA signatures, which crypto/x509 cannot check.
Package certpath verifies certification paths that contain composite ML-DSA or SLH-DSA signatures, which crypto/x509 cannot check.
kemcert
Package kemcert creates certificates for keys that crypto/x509 cannot certify, such as ML-KEM keys (RFC 9935), for the tests and the example mock CA, and test certificates and requests signed with keys it cannot sign with, such as SLH-DSA keys (RFC 9909).
Package kemcert creates certificates for keys that crypto/x509 cannot certify, such as ML-KEM keys (RFC 9935), for the tests and the example mock CA, and test certificates and requests signed with keys it cannot sign with, such as SLH-DSA keys (RFC 9909).
keylimit
Package keylimit bounds the size of public keys taken from a peer, so that one message cannot make a verifier spend minutes in modular arithmetic.
Package keylimit bounds the size of public keys taken from a peer, so that one message cannot make a verifier spend minutes in modular arithmetic.
slhdsasig
Package slhdsasig holds the SLH-DSA identifiers of RFC 9909 and verifies SLH-DSA signatures on certificates, which crypto/x509 and compositex509 cannot check.
Package slhdsasig holds the SLH-DSA identifiers of RFC 9909 and verifies SLH-DSA signatures on certificates, which crypto/x509 and compositex509 cannot check.
Package pkicmp implements the Certificate Management Protocol (CMP) as defined in RFC 9810, with CRMF support per RFC 4211.
Package pkicmp implements the Certificate Management Protocol (CMP) as defined in RFC 9810, with CRMF support per RFC 4211.
Package server implements a CMP server framework that can be embedded in a CA to add CMP support.
Package server implements a CMP server framework that can be embedded in a CA to add CMP support.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL