Documentation
¶
Overview ¶
Package ca is the agent host's gateway CA (gateway.md, "The CA"): a name-constrained ECDSA P-256 certificate authority whose leaves the gateway presents for the hosts it intercepts.
The CA lives in a directory of its own (0700): CertFile (0644) and KeyFile (0600, PKCS #8). Its name constraints permit only the intercepted hosts' DNS names, exclude every IP address, and permit URI and email names only under "invalid", so a leaked key can't mint a certificate a client would accept for any other site. Leaves are minted on first use and kept in a bounded in-memory cache; they never touch the disk.
The PoC has no rotation: LoadOrGenerate makes a CA when there is none, and an expired or out-of-date one is replaced by removing its directory.
Index ¶
Constants ¶
const ( CertFile = "ca.pem" KeyFile = "ca.key" )
The CA directory's files.
Variables ¶
var ErrInvalid = errors.New("ca: invalid gateway CA")
ErrInvalid is wrapped by every refusal of Load: a file of the wrong kind, mode or owner, a certificate that isn't a CA or isn't valid now, or a key that doesn't match it.
Functions ¶
This section is empty.
Types ¶
type CA ¶
type CA struct {
// contains filtered or unexported fields
}
CA signs the gateway's leaves. It is safe for concurrent use.
func Generate ¶
Generate makes a new CA in dir (created 0700 when missing) and returns it. It refuses to replace an existing CertFile or KeyFile. clk times the CA's and its leaves' validity.
func Load ¶
Load reads the CA in dir. Both files are read through one handle on the directory. It refuses (ErrInvalid) a KeyFile that isn't a regular file of this user's with mode 0600, a certificate that isn't a CA or isn't valid on clk, and a key that doesn't match it. A missing directory or file is an fs.ErrNotExist error.
func LoadOrGenerate ¶
LoadOrGenerate loads the CA in dir, or generates one when the directory or the certificate doesn't exist.
func (*CA) CertPEM ¶
CertPEM is the CA certificate in PEM: the public half a workspace's bundle carries.
func (*CA) Certificate ¶
func (c *CA) Certificate() *x509.Certificate
Certificate is the parsed CA certificate.
func (*CA) Leaf ¶
func (c *CA) Leaf(host string) (*tls.Certificate, error)
Leaf is the leaf certificate for host, one of policy.InterceptedHosts (normalised): minted on first use, valid from an hour before for 7 days (capped at the CA's NotAfter), and minted again when less than an hour is left. Its chain holds the CA.