Documentation
¶
Overview ¶
Package pkitest builds small test PKIs at test time: a root, intermediates and leaf variants with exactly the properties a fixture needs. Keys are ECDSA P-256 (fast) unless a fixture asks for RSA. Test support only.
Index ¶
- Variables
- func DER(certs ...*x509.Certificate) [][]byte
- func SCT(s SCTSpec) []byte
- func SCTList(scts []SCTSpec) []byte
- func SmallScalarKey(t testing.TB, curve elliptic.Curve, d int64) *ecdsa.PrivateKey
- type CA
- func (ca *CA) CRL(t testing.TB, revoked []x509.RevocationListEntry, ...) *x509.RevocationList
- func (ca *CA) CrossSign(t testing.TB, sub *CA, o CAOpts) *x509.Certificate
- func (ca *CA) Intermediate(t testing.TB, name string, o CAOpts) *CA
- func (ca *CA) IntermediateWithKey(t testing.TB, name string, o CAOpts, k *ecdsa.PrivateKey) *CA
- func (ca *CA) Leaf(t testing.TB, o LeafOpts) *x509.Certificate
- func (ca *CA) LeafKey(t testing.TB, o LeafOpts) (*x509.Certificate, crypto.Signer)
- func (ca *CA) TLS(t testing.TB, o LeafOpts, chain ...*x509.Certificate) tls.Certificate
- type CAOpts
- type LeafOpts
- type SCTSpec
Constants ¶
This section is empty.
Variables ¶
var Epoch = time.Date(2026, 6, 1, 0, 0, 0, 0, time.UTC)
Epoch is a fixed reference time fixtures are built around, so tests pass their own "now" instead of reading the clock.
Functions ¶
func DER ¶
func DER(certs ...*x509.Certificate) [][]byte
DER returns the raw encodings, in the given order.
func SmallScalarKey ¶ added in v0.4.1
SmallScalarKey returns the ECDSA key whose private scalar is d on curve: the class of key behind the eMudhra compromise (P-384, d < 256), where the public key is d·G and anyone can recover d by counting.
Types ¶
type CA ¶
type CA struct {
Cert *x509.Certificate
Key crypto.Signer
}
CA is a certificate authority that can issue.
func (*CA) CRL ¶ added in v0.4.1
func (ca *CA) CRL(t testing.TB, revoked []x509.RevocationListEntry, thisUpdate, nextUpdate time.Time) *x509.RevocationList
CRL issues a CRL under ca listing revoked, valid from thisUpdate to nextUpdate.
func (*CA) CrossSign ¶ added in v0.4.1
CrossSign issues a second certificate for sub's name and key under ca: the same CA reachable through another issuer.
func (*CA) Intermediate ¶
Intermediate issues a subordinate CA.
func (*CA) IntermediateWithKey ¶ added in v0.4.1
IntermediateWithKey issues a subordinate CA for a key the test chose, for example a deliberately weak one from SmallScalarKey.
func (*CA) TLS ¶
func (ca *CA) TLS(t testing.TB, o LeafOpts, chain ...*x509.Certificate) tls.Certificate
TLS returns a leaf (with its key) and the given chain as a tls.Certificate a test server can present.
type CAOpts ¶
type CAOpts struct {
NotBefore, NotAfter time.Time // default Epoch-1y .. Epoch+10y
PermittedDNS []string
EKU []x509.ExtKeyUsage
CRL []string // CRL distribution points the CA certificate names
}
CAOpts shape a CA certificate.
type LeafOpts ¶
type LeafOpts struct {
CN string
DNS []string
IPs []net.IP
NotBefore, NotAfter time.Time
EKU []x509.ExtKeyUsage // default serverAuth
NoEKU bool
MustStaple bool
OCSP, CRL, AIA []string
SCTs []SCTSpec
RSAExponent int // >0: an RSA-2048 key with this public exponent
Policies []string // dotted OIDs
}
LeafOpts shape a leaf certificate. The zero value is a valid serverAuth leaf for "leaf.test", issued a month before Epoch and valid 90 days.