Documentation
¶
Overview ¶
Package ca manages the certificate authority used to terminate TLS for intercepted hosts.
The material is generated once and then reused, so the trust anchor a client was told to trust keeps working across restarts. Three files are kept:
ca.crt the root certificate — the trust anchor clients install tls.crt the server certificate for the intercepted hosts tls.key its private key, mode 0600
The root's private key is deliberately not among them. It is generated in memory, used once to sign ca.crt and tls.crt, and discarded before the proxy serves anything. Nothing on disk can therefore mint a certificate for a host that is not already in tls.crt: a leaked tls.key impersonates exactly the intercepted hosts, where a leaked CA key would have impersonated anything.
The cost of not keeping the root key is that new material — a new trust anchor — is needed whenever the certificates expire or the set of intercepted hosts grows, and clients have to trust the new ca.crt at that point.
Index ¶
- func CertPathIn(dir string) string
- func ReadCert(dir string) ([]byte, error)
- type Bundle
- func (b *Bundle) CertPEM() []byte
- func (b *Bundle) CertPath() string
- func (b *Bundle) GetCertificate(fallbackHost string) func(*tls.ClientHelloInfo) (*tls.Certificate, error)
- func (b *Bundle) Hosts() []string
- func (b *Bundle) IssuedNow() bool
- func (b *Bundle) IssuedReason() string
- func (b *Bundle) Leaf(host string) (*tls.Certificate, error)
- func (b *Bundle) NotAfter() time.Time
- func (b *Bundle) Root() *x509.Certificate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CertPathIn ¶
CertPathIn reports where the root certificate lives for a given directory, without creating anything.
Types ¶
type Bundle ¶
type Bundle struct {
// contains filtered or unexported fields
}
Bundle is the certificate material for one run.
func Open ¶
Open returns the certificate material for hosts, reusing what is stored in dir when it is still valid and covers every host, and creating it otherwise.
func (*Bundle) CertPath ¶
CertPath reports the PEM file holding the root certificate. This is the file clients must trust (for Claude Code: NODE_EXTRA_CA_CERTS).
func (*Bundle) GetCertificate ¶
func (b *Bundle) GetCertificate(fallbackHost string) func(*tls.ClientHelloInfo) (*tls.Certificate, error)
GetCertificate is a tls.Config.GetCertificate callback. It falls back to fallbackHost when the client omits SNI or asks for a name this bundle does not cover.
func (*Bundle) IssuedReason ¶
IssuedReason explains why new material was created.
func (*Bundle) Leaf ¶
func (b *Bundle) Leaf(host string) (*tls.Certificate, error)
Leaf returns the certificate for host. host may carry a port, which is stripped. Only the hosts the certificate was issued for are available: the root key is gone, so nothing else can be signed.
func (*Bundle) NotAfter ¶
NotAfter reports when the material stops being usable, which is the earlier of the two certificates' expiries.
func (*Bundle) Root ¶
func (b *Bundle) Root() *x509.Certificate
Root exposes the parsed root certificate.