cryptotest

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func CAPEM

func CAPEM(t testing.TB, commonName string) []byte

CAPEM is a convenience for tests that only need a fresh CA certificate blob.

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.

Jump to

Keyboard shortcuts

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