Documentation
¶
Overview ¶
Package pki is the pki endpoint group: the certificates of the fleet, the controller's and each agent's, through the API. osapi pki cert reads the certificates of the host that it runs on.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("certificate not found")
ErrNotFound is a certificate that no host has.
var Group = endpoint.Register(endpoint.Define( "pki", "The certificates of the fleet, and the rotation of the controller's key and of the NATS server's certificate", endpoint.Area(area.Fleet), endpoint.SubDoc("cert", "Read the certificates of the controller and of each agent"), endpoint.SubDoc("key", "Rotate the controller's key with no new admission of the agents"), endpoint.SubDoc("nats", "Rotate the NATS server's certificate with no restart and no new join of the agents"), endpoint.Title("PKI API"), endpoint.Tag( "pki_operations", "PKI", "The certificates of the fleet, and the rotation of the controller's key and of "+ "the NATS server's certificate.", ), endpoint.Uses[Deps](), endpoint.Get[ListInput, CertList]("list"). Handle(List). Sub("cert"). Use("list"). ID("ListPKICerts"). Describe("List the certificates of the fleet"). Explain("Lists the certificates of the controller's host, the API's, the "+ "controller's metrics and the NATS server's, and the certificates that each "+ "agent reports in its registration, with their expiry. A certificate that a "+ "host has not made is not made."). Returns("The certificates of each host."). Command("List the certificates of the fleet", "Lists the certificates of the controller and of each agent, with the\n"+ "days that are left until each expires. osapi pki cert list reads only\n"+ "the host that it runs on."). Example(""). Example("--hostname web-01"). Prints(sampleList). Fails("a hostname over 255 characters", ListInput{Hostname: strings.Repeat("a", 256)}), endpoint.Get[GetInput, Cert]("get"). Handle(Get). Sub("cert"). Use("get"). Key("name"). ID("GetPKICert"). Describe("Get one certificate of a host"). Explain("Reads one certificate of one host: the controller's host when the "+ "hostname is empty, or the agent of the hostname."). Returns("The certificate."). Command("Get one certificate of a host", "Shows one certificate in full: its names, its fingerprint and its\n"+ "algorithms. With no hostname, it is a certificate of the controller's\n"+ "host, such as api."). Example("--name api"). Example("--name agent-metrics --hostname web-01"). Prints(sampleCert). Errors(endpoint.NotFound(ErrNotFound, "The host has no certificate with that name.")). Fails("a name over 64 characters", GetInput{Name: strings.Repeat("a", 65)}). Fails("a hostname over 255 characters", GetInput{Name: "api", Hostname: strings.Repeat("a", 256)}), endpoint.Get[RotationInput, Rotation]("rotation"). Handle(KeyRotation). Sub("key"). Use("get"). ID("GetPKIKeyRotation"). Describe("Show the rotation of the controller's key"). Explain("Shows the key that the controller signs jobs with, and during a "+ "rotation the key that it switches to, when it switches at the latest, and "+ "each admitted agent that the switch waits for, with whether it has the "+ "next key."). Returns("The rotation of the controller's key."). Command("Show the rotation of the controller's key", "Shows the controller's key, and during a rotation, each agent that the\n"+ "switch waits for. The controller switches when each one has the next key,\n"+ "or when controller.pki.rotation_grace_period ends."). Example(""). Prints(sampleRotation), endpoint.Post[RotateInput, Rotation]("rotate"). AdminOnly(). Handle(RotateKey). Sub("key"). Use("rotate"). ID("RotatePKIKey"). Describe("Rotate the controller's key"). Explain("Starts the rotation of the controller's key, with no new admission "+ "of the agents. The controller makes the next key, and signs a record "+ "that gives it to the agents with its current key. Each agent takes it at "+ "its next heartbeat. The controller switches to the next key when each "+ "admitted agent that reported within controller.pki.rotation_grace_period "+ "has it, or when the grace period ends. An agent that does not have it "+ "then needs a new admission. A rotation in progress is not started again."). Returns("The rotation that started, or the one in progress."). Command("Rotate the controller's key", "Starts the rotation of the controller's key. The agents take the next key\n"+ "at their next heartbeat, and the controller switches when each one has it.\n"+ "osapi client pki key get shows the progress. An agent that is away\n"+ "for the whole grace period needs a new admission."). Example(""). Check("client pki key get", "", "next", "{out.next}"). Prints(sampleRotationStarted), endpoint.Get[CertRotationInput, CertRotation]("natscertrotation"). Handle(NATSCertRotation). Sub("nats"). Use("get"). ID("GetPKINATSCertRotation"). Describe("Show the rotation of the NATS server's certificate"). Explain("Shows the certificate that the NATS server serves, and during a "+ "rotation the certificate that it switches to, when it switches at the "+ "latest, and each admitted agent that the switch waits for, with whether "+ "it trusts the next certificate."). Returns("The rotation of the NATS server's certificate."). Command("Show the rotation of the NATS server's certificate", "Shows the NATS server's certificate, and during a rotation, each agent that\n"+ "the switch waits for. The controller switches when each one trusts the next\n"+ "certificate, or when controller.pki.rotation_grace_period ends."). Example(""). Prints(sampleCertRotation), endpoint.Post[CertRotateInput, CertRotation]("natscertrotate"). AdminOnly(). Handle(RotateNATSCert). Sub("nats"). Use("rotate"). ID("RotatePKINATSCert"). Describe("Rotate the NATS server's certificate"). Explain("Starts the rotation of the NATS server's self-signed certificate, "+ "which each joined agent pins, with no restart and no new join. The "+ "controller makes the next certificate beside the current one, and signs a "+ "record that gives both to the agents. Each agent trusts the next one at its "+ "next heartbeat. The controller renames it into place when each admitted "+ "agent that reported within controller.pki.rotation_grace_period trusts it, "+ "or when the grace period ends, and NATS serves it at its next handshake. A "+ "rotation in progress is not started again. It runs on the controller's host, "+ "which must hold the NATS server's certificate, and refuses a certificate of "+ "the operator's cert_file."). Returns("The rotation that started, or the one in progress."). Command("Rotate the NATS server's certificate", "Starts the rotation of the NATS server's certificate. The agents trust the\n"+ "next certificate at their next heartbeat, and the controller switches when\n"+ "each one does. osapi client pki nats get shows the progress."). Example(""). Check("client pki nats get", "", "next", "{out.next}"). Prints(sampleCertRotationStarted). Errors(endpoint.Conflict( certrotation.ErrOperatorCert, "The NATS server serves a certificate of the operator's cert_file: replace that file.", )), ))
Group is the pki group's definition. The routes, the spec, the CLI commands and their pages come from it.
Functions ¶
This section is empty.
Types ¶
type Cert ¶
type Cert struct {
Hostname string `` /* 177-byte string literal not displayed */
Name string `` /* 184-byte string literal not displayed */
State string `` /* 173-byte string literal not displayed */
Component string `` /* 176-byte string literal not displayed */
Source string `` /* 182-byte string literal not displayed */
File string `` /* 194-byte string literal not displayed */
Names []string `` /* 194-byte string literal not displayed */
Expires time.Time ` json:"expires,omitzero" doc:"When the certificate expires."`
DaysLeft *int `` /* 212-byte string literal not displayed */
Fingerprint string `` /* 194-byte string literal not displayed */
Key string `` /* 129-byte string literal not displayed */
Signature string `` /* 194-byte string literal not displayed */
FIPS *bool `` /* 216-byte string literal not displayed */
// contains filtered or unexported fields
}
Cert is one certificate of one host: the controller's own, or one that an agent reports in its registration.
type CertList ¶
type CertList struct {
Items []Cert ` json:"items"`
Total int ` json:"total_items" doc:"The number of certificates."`
// contains filtered or unexported fields
}
CertList is the certificate of each host, with the total.
type CertRotateInput ¶
type CertRotateInput struct{}
CertRotateInput is the input of nats rotate: it has no field.
type CertRotation ¶
type CertRotation struct {
Current string `` /* 269-byte string literal not displayed */
Next string `` /* 269-byte string literal not displayed */
StartedAt time.Time ` json:"started_at,omitzero" doc:"When the rotation started."`
SwitchBy time.Time `` /* 287-byte string literal not displayed */
Agents []CertRotationAgent `` /* 181-byte string literal not displayed */
// contains filtered or unexported fields
}
CertRotation is the NATS server's certificate and its rotation.
func NATSCertRotation ¶
func NATSCertRotation( ctx context.Context, d Deps, _ CertRotationInput, ) (CertRotation, error)
NATSCertRotation is the rotation of the NATS server's certificate now.
func RotateNATSCert ¶
func RotateNATSCert( ctx context.Context, d Deps, _ CertRotateInput, ) (CertRotation, error)
RotateNATSCert starts the rotation of the NATS server's certificate, or shows the one in progress.
type CertRotationAgent ¶
type CertRotationAgent struct {
Hostname string `` /* 151-byte string literal not displayed */
MachineID string `` /* 177-byte string literal not displayed */
HasNext bool `` /* 194-byte string literal not displayed */
// contains filtered or unexported fields
}
CertRotationAgent is one agent that the switch of a certificate's rotation waits for.
type CertRotationInput ¶
type CertRotationInput struct{}
CertRotationInput is the input of nats get: it has no field.
type CertRotator ¶
type CertRotator interface {
Start(ctx context.Context) (certrotation.Status, error)
Status(ctx context.Context) (certrotation.Status, error)
}
CertRotator starts and shows the rotation of the NATS server's certificate. A *certrotation.Rotation is one.
type Deps ¶
type Deps struct {
Agents Agents
// Local are the certificates of the controller's host, the controller's
// and the NATS server's, as the controller reads them now. Nil is none.
Local func() []pki.Cert
// Hostname is the hostname of the controller's host.
Hostname string
// Rotation starts and shows the rotation of the controller's key.
Rotation Rotator
// CertRotation starts and shows the rotation of the NATS server's
// certificate.
CertRotation CertRotator
}
Deps is what the group's handlers use: the agents, whose registrations have their certificates, and the controller's own certificates.
type GetInput ¶
type GetInput struct {
Name string `` /* 136-byte string literal not displayed */
Hostname string `` /* 184-byte string literal not displayed */
}
GetInput names one certificate of one host.
type ListInput ¶
type ListInput struct {
Hostname string `` /* 155-byte string literal not displayed */
}
ListInput filters the certificates: a hostname gives only that host's.
type RotateInput ¶
type RotateInput struct{}
RotateInput is the input of key rotate: it has no field.
type Rotation ¶
type Rotation struct {
Current string `` /* 255-byte string literal not displayed */
Next string `` /* 255-byte string literal not displayed */
StartedAt time.Time ` json:"started_at,omitzero" doc:"When the rotation started."`
SwitchBy time.Time `` /* 273-byte string literal not displayed */
Agents []RotationAgent `` /* 174-byte string literal not displayed */
// contains filtered or unexported fields
}
Rotation is the controller's key and its rotation.
func KeyRotation ¶
KeyRotation is the rotation of the controller's key now.
type RotationAgent ¶
type RotationAgent struct {
Hostname string `` /* 135-byte string literal not displayed */
MachineID string `` /* 161-byte string literal not displayed */
HasNext bool `` /* 178-byte string literal not displayed */
// contains filtered or unexported fields
}
RotationAgent is one agent that the switch of a rotation waits for.
type RotationInput ¶
type RotationInput struct{}
RotationInput is the input of key get: it has no field.