Documentation
¶
Overview ¶
Package tlsconftest issues throwaway certificates for tests that need TLS or mutual TLS, in the spirit of net/http/httptest.
Index ¶
- type Pair
- func (p Pair) CertPEM() []byte
- func (p Pair) Client(t testing.TB, cn string) Pair
- func (p Pair) Issue(t testing.TB, tmpl *x509.Certificate) Pair
- func (p Pair) IssueCert(t testing.TB, tmpl *x509.Certificate, pub crypto.PublicKey) *x509.Certificate
- func (p Pair) IssueKey(t testing.TB, tmpl *x509.Certificate, key *ecdsa.PrivateKey) Pair
- func (p Pair) Pool() *x509.CertPool
- func (p Pair) Renew(t testing.TB, leaf Pair) Pair
- func (p Pair) Server(t testing.TB) Pair
- func (p Pair) TLS() tls.Certificate
- func (p Pair) Thumbprint(t testing.TB) string
- func (p Pair) UnnamedClient(t testing.TB) Pair
- func (p Pair) Write(t testing.TB, dir, name string) (certFile, keyFile string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pair ¶
type Pair struct {
Cert *x509.Certificate
Key *ecdsa.PrivateKey
}
Pair is a certificate and its private key.
func SelfSigned ¶
func SelfSigned(t testing.TB, tmpl *x509.Certificate) Pair
SelfSigned issues tmpl signed by its own fresh key. It fills in the serial number and a validity window around now.
func (Pair) IssueCert ¶
func (p Pair) IssueCert(t testing.TB, tmpl *x509.Certificate, pub crypto.PublicKey) *x509.Certificate
IssueCert signs tmpl with p, which must be a CA, over pub of any type.
func (Pair) IssueKey ¶
func (p Pair) IssueKey(t testing.TB, tmpl *x509.Certificate, key *ecdsa.PrivateKey) Pair
IssueKey signs tmpl with p, which must be a CA, over key.
func (Pair) Renew ¶
Renew is a new certificate from p over leaf's key, with leaf's subject, names and usage, the way cert-manager renews without rotating the key.
func (Pair) TLS ¶
func (p Pair) TLS() tls.Certificate
TLS is p as a certificate to present in a handshake.
func (Pair) Thumbprint ¶
Thumbprint is the RFC 7638 thumbprint of p's key, the cnf jkt of a grant bound to p. It is computed here because tlsconf's internal tests import this package, so importing tlsconf would be a cycle.
func (Pair) UnnamedClient ¶
UnnamedClient is a client certificate from p over a fresh P-224 key. Go issues and parses the curve, and the key has no RFC 7638 thumbprint, so the certificate names no caller.