Documentation
¶
Overview ¶
Package pkicert is osapi pki cert: it shows and rotates the TLS certificates that the servers of osapi serve on this host, the self-signed ones that each makes at its first start and a cert_file of the operator.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoCert = errors.New("no certificate with this name: list shows each") ErrNotMade = errors.New("not made") ErrOperatorCert = certrotation.ErrOperatorCert )
Errors of get and rotate.
var ( SampleCert = CertInfo{ Name: "api", State: "ok", Component: "controller", Source: "self-signed", File: "/etc/osapi/pki/api.crt", Names: []string{"localhost", "controller.example.com", "127.0.0.1"}, Expires: time.Date(2031, 11, 25, 12, 0, 0, 0, time.UTC), DaysLeft: new(1825), Fingerprint: "SHA256:1f53dea6b0c3e2f9a8d4c71e5b6a0f2d9c8e7b6a5f4e3d2c1b0a9f8e7d6c5b4a", Key: "ECDSA P-256", Signature: "ECDSA-SHA256", FIPS: new(true), } SampleList = ListOutput{Items: []CertInfo{SampleCert, { Name: "agent-metrics", State: "not made", Component: "agent", Source: "self-signed", File: "/etc/osapi/pki/agent/agent-metrics.crt", }}} SampleRotate = RotateOutput{Cert: SampleCert, Next: "restart the server to serve it"} )
The sample outputs of the examples, which the docs page of each cert group shows.
var Group = command.Register(command.Define( "cert", "Show and rotate the TLS certificates of osapi on this host", command.Under(command.ParentPKI), command.Uses[Deps](), command.Method[ListInput, ListOutput]("list"). Short("List the certificates, with their state, algorithms and expiry"). Long("Run this on the host. It reads each certificate that the API, the NATS\n"+ "server and the metrics servers serve: the self-signed one in the key\n"+ "directory of the component, or the cert_file of the config. Each of the\n"+ "five is in the list. A component that has not started on this host made\n"+ "no certificate: its state is not made. Run it on the host of the server;\n"+ "a client config reads no certificate."). Example(""). Prints(SampleList). Handle(List), command.Method[GetInput, CertInfo]("get"). Short("Show one certificate in full: its names, algorithms and fingerprint"). Example("--name api"). Prints(SampleCert). Fails("no name", GetInput{}). Fails("a name of more than 64 characters", GetInput{Name: strings.Repeat("a", 65)}). Handle(Get), command.Method[RotateInput, RotateOutput]("rotate"). Short("Make a new self-signed certificate in place of the old one"). Long("It replaces a self-signed certificate; the server serves the new one at\n"+ "its next start. It refuses a cert_file of the operator: replace that file.\n"+ "Each join string pins the NATS server's certificate, and each joined agent\n"+ "trusts it: a new one cuts those agents off, so it needs --force, then new\n"+ "join tokens and a join again of each agent."). Example("--name api"). Prints(SampleRotate). Fails("no name", RotateInput{}). Fails("a name of more than 64 characters", RotateInput{Name: strings.Repeat("a", 65)}). Handle(Rotate), ))
Group is osapi pki cert.
Functions ¶
This section is empty.
Types ¶
type CertInfo ¶
type CertInfo struct {
Name string `json:"name"`
State string `` /* 131-byte string literal not displayed */
Component string `json:"component"`
Source string `json:"source" doc:"self-signed, which osapi made, or cert_file, the operator's."`
File string `` /* 141-byte string literal not displayed */
Names []string `` /* 141-byte string literal not displayed */
Expires time.Time `json:"expires"`
DaysLeft *int `` /* 159-byte string literal not displayed */
Fingerprint string `` /* 141-byte string literal not displayed */
Key string `json:"key" doc:"The algorithm and size of the public key, such as ECDSA P-256."`
Signature string `` /* 141-byte string literal not displayed */
FIPS *bool `` /* 163-byte string literal not displayed */
}
CertInfo is a certificate as list and get show it.
type Deps ¶
type Deps struct {
FS avfs.VFS
Certs func() []pki.CertSource
Now func() time.Time
Audit func(ctx context.Context, e audit.Entry) error
Config config.Config
Dial func(ctx context.Context) (certrotation.KV, func(), error)
}
Deps is what the cert commands use: the file system, the certificates of each component on this host, the time now, the record of a change in the audit log, or nil, and, for a rotation of the NATS server's certificate, the config and a connection to NATS as the controller makes it.
type GetInput ¶
type GetInput struct {
Name string `json:"name" validate:"required,max=64" doc:"The name of the certificate, as list shows it, such as api or nats."`
}
GetInput names a certificate.
type ListOutput ¶
type ListOutput struct {
Items []CertInfo `json:"items"`
}
ListOutput is each certificate.
type RotateInput ¶
type RotateInput struct {
Name string `json:"name" validate:"required,max=64" doc:"The name of the certificate, as list shows it, such as api or nats."`
}
RotateInput names a certificate, and whether to rotate one that agents pin.
type RotateOutput ¶
type RotateOutput struct {
Cert CertInfo ` json:"cert"`
NextCert string `` /* 151-byte string literal not displayed */
Next string ` json:"next"`
// contains filtered or unexported fields
}
RotateOutput is the certificate that rotate made.
func Rotate ¶
func Rotate( ctx context.Context, d Deps, in RotateInput, ) (RotateOutput, error)
Rotate makes a new self-signed certificate in place of src's, which its server serves at its next handshake, with no restart. The NATS server's certificate, which each joined agent pins, rotates with an overlap: the controller gives the agents the next certificate, and switches to it when they trust it.