Documentation
¶
Overview ¶
Package tlstest makes certificate authorities and TLS servers whose leaf a given authority signed, so a test can show that a client trusts one CA and refuses another. httptest.NewTLSServer cannot show that: every server it starts presents the same built-in certificate.
The package is imported only from tests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CA ¶
type CA struct {
// contains filtered or unexported fields
}
CA is a certificate authority that exists for the length of one test.
func NewCA ¶
NewCA creates a CA and writes its certificate to a PEM file under t.TempDir(), which File returns.
func (*CA) File ¶
File returns the path of a PEM file that holds the CA certificate and nothing else.
func (*CA) Server ¶
Server starts an HTTPS server for h whose certificate the CA signed for 127.0.0.1, ::1 and localhost. The server sends that leaf alone, without the CA certificate, so a client completes the handshake only when it already trusts the CA. The server is closed when the test ends.
The client that srv.Client() returns trusts the leaf directly, so a test that proves verification must use the client it is testing instead.