Documentation
¶
Overview ¶
Package ca is the emulator's local certificate authority (Section 7.4). On first start a root CA is created in the instance directory (ca.pem, ca-key.pem, mode 0600); it signs Google-managed certificates for load balancers (FR-LB-004), host-mode serving certificates (FR-CORE-043) and anything else that must chain to a root the user trusts once.
Index ¶
Constants ¶
const ( CertFile = "ca.pem" KeyFile = "ca-key.pem" )
File names inside the instance directory.
const DefaultLeafValidity = 90 * 24 * time.Hour
DefaultLeafValidity is the lifetime of issued leaf certificates (Google-managed certificates are valid for 90 days).
Variables ¶
This section is empty.
Functions ¶
func EncodeCert ¶
func EncodeCert(cert *tls.Certificate) (chainPEM, keyPEM []byte, err error)
EncodeCert returns the PEM chain and PEM private key of a tls.Certificate.
Types ¶
type CA ¶
type CA struct {
// contains filtered or unexported fields
}
CA is a root certificate authority backed by files in a directory.
func (*CA) Certificate ¶
func (c *CA) Certificate() *x509.Certificate
Certificate returns the root certificate.
func (*CA) Issue ¶
func (c *CA) Issue(l Leaf) (*tls.Certificate, error)
Issue signs a new leaf certificate with a fresh P-256 key.
func (*CA) Rotate ¶
Rotate replaces the root CA with a new one (`gcpemu ca rotate`). Leaf certificates issued by the old root stop verifying once clients trust only the new one.
func (*CA) ServerCert ¶
func (c *CA) ServerCert(names ...string) (*tls.Certificate, error)
ServerCert returns a cached serving certificate for the given names, issuing (or re-issuing near expiry) as needed.
type Leaf ¶
type Leaf struct {
// DNSNames and IPs become SANs; the first DNS name (or IP) is the CN.
DNSNames []string
IPs []net.IP
// Validity defaults to DefaultLeafValidity.
Validity time.Duration
// Client adds the clientAuth extended key usage (serverAuth is always set
// unless ClientOnly).
Client bool
ClientOnly bool
// Organization for the subject (optional).
Organization string
}
Leaf describes a certificate to issue.