Skip to main content

Certificate

CA certificate management on target hosts. Certificates are deployed as PEM files from the Object Store and installed into the system trust store.

Methods​

MethodDescription
List(ctx, hostname)List all CA certificates
Create(ctx, hostname, opts)Deploy a custom CA certificate
Update(ctx, hostname, name, opts)Redeploy a custom CA certificate
Delete(ctx, hostname, name)Remove a custom CA certificate

Request Types​

TypeFields
CertificateCreateOptsName (required), Object (required)
CertificateUpdateOptsObject (required)

Usage​

import "github.com/osapi-io/osapi/pkg/sdk/client"

c := client.New("http://localhost:8080", token)

// List all CA certificates
resp, err := c.Certificate.List(ctx, "web-01")
for _, r := range resp.Data.Results {
for _, cert := range r.Certificates {
fmt.Printf("%s source=%s\n", cert.Name, cert.Source)
}
}

// Create a custom CA certificate
resp, err := c.Certificate.Create(ctx, "web-01",
client.CertificateCreateOpts{
Name: "internal-ca",
Object: "internal-ca",
})

// Update a certificate with a new object
resp, err := c.Certificate.Update(ctx, "web-01", "internal-ca",
client.CertificateUpdateOpts{
Object: "internal-ca-v2",
})

// Delete a certificate
resp, err := c.Certificate.Delete(ctx, "web-01", "internal-ca")

Example​

See examples/sdk/client/certificate.go for a complete working example.

Permissions​

OperationPermission
Listcertificate:read
Create, Update, Deletecertificate:write

Certificate management is supported on the Debian OS family (Ubuntu, Debian, Raspbian). On unsupported platforms (Darwin, generic Linux), operations return status: skipped.