Documentation
¶
Overview ¶
Package cryptotest provides shared X.509 test fixtures so the sdk and agent test suites do not each re-implement ECDSA P-256 certificate construction (WS16b DRY). It is a regular (non-_test) package so it can be imported across packages and repos; it therefore deliberately uses FIXED validity bounds rather than time.Now() — the module's clock seam forbids time.Now() outside _test files, and a wide fixed window is "valid now" for any realistic test run while staying within the ASN.1 GeneralizedTime range.
Index ¶
- func CAPEM(t testing.TB, commonName string) []byte
- func EncodeCertPEM(cert *x509.Certificate) []byte
- func GenCA(t testing.TB, commonName string) (caPEM []byte, key *ecdsa.PrivateKey, cert *x509.Certificate)
- func GenLeaf(t testing.TB, ca *x509.Certificate, caKey *ecdsa.PrivateKey, commonName string, ...) (certPEM, keyPEM []byte)
- func GenSubCA(t testing.TB, commonName string, parent *x509.Certificate, ...) []byte
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeCertPEM ¶
func EncodeCertPEM(cert *x509.Certificate) []byte
EncodeCertPEM PEM-encodes an already-parsed certificate.
func GenCA ¶
func GenCA(t testing.TB, commonName string) (caPEM []byte, key *ecdsa.PrivateKey, cert *x509.Certificate)
GenCA returns a self-signed test CA: its PEM-encoded certificate, its private key, and the parsed certificate (for signing leaves / building pools).
func GenLeaf ¶
func GenLeaf(t testing.TB, ca *x509.Certificate, caKey *ecdsa.PrivateKey, commonName string, server bool) (certPEM, keyPEM []byte)
GenLeaf issues a leaf certificate (server or client) signed by ca/caKey and returns the PEM-encoded certificate and key. Server leaves carry localhost SANs (127.0.0.1, ::1, localhost) so they work for httptest TLS servers.
func GenSubCA ¶
func GenSubCA(t testing.TB, commonName string, parent *x509.Certificate, parentKey *ecdsa.PrivateKey) []byte
GenSubCA returns a sub-CA certificate PEM signed by parent/parentKey.
Types ¶
This section is empty.