Certificate
The certificate authorities that the host trusts.
osapi dsl behavior get --name certificate and osapi dsl behavior method get
show the same. Its chain shows each
call that its examples make.
Behavior
| Name | certificate |
| Description | The certificate authorities that the host trusts |
| Placement | node |
| Area | security |
| Internal | no |
| API | yes |
| CLI | yes |
| Next | no |
| Platforms | debian, suse, linux, darwin |
| Sudo | update-ca-certificates, update-ca-trust |
| Runs | none |
| Writes | /usr/local/share/ca-certificates/osapi-*.crt, /etc/pki/ca-trust/source/anchors/osapi-*.crt, /etc/pki/trust/anchors/osapi-*.crt, /etc/ca-certificates/trust-source/anchors/osapi-*.crt |
| Keeps state | no |
| Uses | object, managedfile |
| Used by | none |
Methods (5)
| NAME | VERB | HTTP | ROUTE | PERMISSION | DESCRIPTION |
|---|---|---|---|---|---|
| list | read | GET | /api/node/{hostname}/certificate | certificate:read | List the certificate authorities that the host trusts |
| get | read | GET | /api/node/{hostname}/certificate/{name} | certificate:read | Get one certificate authority |
| create | write | POST | /api/node/{hostname}/certificate | certificate:write | Add a certificate authority to the trust store |
| update | write | PUT | /api/node/{hostname}/certificate/{name} | certificate:write | Write a certificate authority that osapi deployed again |
| delete | write | DELETE | /api/node/{hostname}/certificate/{name} | certificate:write | Remove a certificate authority that osapi deployed |
Types (5)
| NAME | INPUT | OUTPUT |
|---|---|---|
| list | ListInput | []Entry { name, path, source, enabled, subject, fingerprint, not_after, managed, object } |
| get | GetInput { name* } | Entry { name, path, source, enabled, subject, fingerprint, not_after, managed, object } |
| create | CreateInput { name*, object* } | Result { name, changed } |
| update | UpdateInput { name*, object } | Result { name, changed } |
| delete | DeleteInput { name* } | Result { name, changed } |
Settings (0)
None. Declare them with behavior.Config.
Telemetry
| Span | behavior.certificate.<method> |
| Child spans | behavior.object.<method>, behavior.managedfile.<method>, exec update-ca-certificates, exec update-ca-trust, exec security, exec chown, exec stat, file.write, file.remove, file.chmod, kv.get, kv.put |
| Metrics | osapi_behavior_calls_total, osapi_behavior_duration_seconds, osapi_behavior_changes_total |
| Attributes | osapi.behavior.name, osapi.behavior.method, osapi.behavior.verb, osapi.behavior.outcome, osapi.behavior.changed |
| Recorded inputs | name (get, create, update, delete) |
Method list
| Name | list |
| Verb | read |
| Description | List the certificate authorities that the host trusts |
| Detail | Lists each CA of the trust store through gohai: the distribution's and the local ones on Linux, from the family's directories, and the system keychains on macOS, each with its subject, fingerprint and expiry. A CA that osapi deployed reads by the name that it was deployed with, not its file's osapi- name, and is managed. |
| HTTP | GET |
| Route | /api/node/{hostname}/certificate |
| Permission | certificate:read |
| Command | osapi client node certificate list |
| Input type | ListInput |
| Output type | []Entry |
Input (0)
None. The method takes no input; its command needs only --target.
Output (9)
| FIELD | TYPE | DESCRIPTION |
|---|---|---|
| name | string | The CA: the name it was deployed with for a CA that osapi deployed, else its file's name |
| path | string | The file, or on macOS the keychain, that has it |
| source | string | system for a CA of the distribution, local for one an administrator added |
| enabled | boolean | Whether the host trusts it: false for a system CA that the trust store turns off |
| subject | string | Its subject, such as CN=ISRG Root X1,O=Internet Security Research Group,C=US |
| fingerprint | string | The SHA-256 of the certificate, in hex |
| not_after | string | When it expires |
| managed | boolean | Whether osapi deployed it, and its writes change it |
| object | string | The object that osapi deployed it from |
Examples (5)
| EXAMPLE | INPUT | OUTPUT |
|---|---|---|
| A Debian host with a system CA | (none) | [enabled=true, fingerprint=6513d3f115f766cdffa3922e5ee47c4cccc98475cbe6471c5d32ddd4104c2312, managed=false, name=mozilla/Example_Root, not_after=2126-10-29T23:38:01Z, path=/usr/share/ca-certificates/mozilla/Example_Root.crt, source=system, subject=CN=osapi example CA,O=osapi] |
| A CA that osapi deployed reads by its name | (none) | [enabled=true, fingerprint=6513d3f115f766cdffa3922e5ee47c4cccc98475cbe6471c5d32ddd4104c2312, managed=false, name=mozilla/Example_Root, not_after=2126-10-29T23:38:01Z, path=/usr/share/ca-certificates/mozilla/Example_Root.crt, source=system, subject=CN=osapi example CA,O=osapi] [enabled=true, fingerprint=6513d3f115f766cdffa3922e5ee47c4cccc98475cbe6471c5d32ddd4104c2312, managed=true, name=internal-ca, not_after=2126-10-29T23:38:01Z, object=internal-ca.pem, path=/usr/local/share/ca-certificates/osapi-internal-ca.crt, source=local, subject=CN=osapi example CA,O=osapi] |
| A host of the RHEL family | (none) | [enabled=true, fingerprint=6513d3f115f766cdffa3922e5ee47c4cccc98475cbe6471c5d32ddd4104c2312, managed=false, name=anchors/Example_Root, not_after=2126-10-29T23:38:01Z, path=/usr/share/pki/ca-trust-source/anchors/Example_Root.pem, source=system, subject=CN=osapi example CA,O=osapi] |
| A CA that osapi deployed on SUSE | (none) | [enabled=true, fingerprint=6513d3f115f766cdffa3922e5ee47c4cccc98475cbe6471c5d32ddd4104c2312, managed=true, name=internal-ca, not_after=2126-10-29T23:38:01Z, object=internal-ca.pem, path=/etc/pki/trust/anchors/osapi-internal-ca.crt, source=local, subject=CN=osapi example CA,O=osapi] |
| A Mac | (none) | [enabled=true, fingerprint=6513d3f115f766cdffa3922e5ee47c4cccc98475cbe6471c5d32ddd4104c2312, managed=false, name=osapi example CA, not_after=2126-10-29T23:38:01Z, path=/System/Library/Keychains/SystemRootCertificates.keychain, source=system, subject=CN=osapi example CA,O=osapi] |
Method get
| Name | get |
| Verb | read |
| Description | Get one certificate authority |
| Detail | Reads one CA from the same list, by the name that list gives it. A CA that the host does not trust is not found. A name with a slash, such as a system CA of the Debian family, is in list only. |
| HTTP | GET |
| Route | /api/node/{hostname}/certificate/{name} |
| Permission | certificate:read |
| Command | osapi client node certificate get |
| Input type | GetInput |
| Output type | Entry |
Input (1)
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|---|---|---|---|
| name | string | yes | pattern ^[^/%\x00-\x1f\x7f]+$, max length 255 | The CA, as list names it, such as internal-ca, or ISRG Root X1 on macOS; a name with a slash, such as mozilla/ISRG_Root_X1, is in list only, because a path segment cannot have one |
Output (9)
| FIELD | TYPE | DESCRIPTION |
|---|---|---|
| name | string | The CA: the name it was deployed with for a CA that osapi deployed, else its file's name |
| path | string | The file, or on macOS the keychain, that has it |
| source | string | system for a CA of the distribution, local for one an administrator added |
| enabled | boolean | Whether the host trusts it: false for a system CA that the trust store turns off |
| subject | string | Its subject, such as CN=ISRG Root X1,O=Internet Security Research Group,C=US |
| fingerprint | string | The SHA-256 of the certificate, in hex |
| not_after | string | When it expires |
| managed | boolean | Whether osapi deployed it, and its writes change it |
| object | string | The object that osapi deployed it from |
Examples (4)
| EXAMPLE | INPUT | OUTPUT |
|---|---|---|
| A CA that osapi deployed, by the name it was deployed with | name=internal-ca | name=internal-ca, path=/usr/local/share/ca-certificates/osapi-internal-ca.crt, source=local, enabled=true, subject=CN=osapi example CA,O=osapi, fingerprint=6513d3f115f766cdffa3922e5ee47c4cccc98475cbe6471c5d32ddd4104c2312, not_after=2126-10-29T23:38:01Z, managed=true, object=internal-ca.pem |
| A CA that osapi deployed on the RHEL family | name=internal-ca | name=internal-ca, path=/etc/pki/ca-trust/source/anchors/osapi-internal-ca.crt, source=local, enabled=true, subject=CN=osapi example CA,O=osapi, fingerprint=6513d3f115f766cdffa3922e5ee47c4cccc98475cbe6471c5d32ddd4104c2312, not_after=2126-10-29T23:38:01Z, managed=true, object=internal-ca.pem |
| A CA that osapi deployed on SUSE | name=internal-ca | name=internal-ca, path=/etc/pki/trust/anchors/osapi-internal-ca.crt, source=local, enabled=true, subject=CN=osapi example CA,O=osapi, fingerprint=6513d3f115f766cdffa3922e5ee47c4cccc98475cbe6471c5d32ddd4104c2312, not_after=2126-10-29T23:38:01Z, managed=true, object=internal-ca.pem |
| A CA of a Mac | name=osapi example CA | name=osapi example CA, path=/System/Library/Keychains/SystemRootCertificates.keychain, source=system, enabled=true, subject=CN=osapi example CA,O=osapi, fingerprint=6513d3f115f766cdffa3922e5ee47c4cccc98475cbe6471c5d32ddd4104c2312, not_after=2126-10-29T23:38:01Z, managed=false |
Method create
| Name | create |
| Verb | write |
| Description | Add a certificate authority to the trust store |
| Detail | Writes the PEM of the object as a file with the osapi- prefix, such as osapi-internal-ca.crt for internal-ca, in the family's local directory: /usr/local/share/ca-certificates on the Debian family, /etc/pki/trust/anchors on SUSE, /etc/pki/ca-trust/source/anchors on RHEL and Fedora. Then it rebuilds the trust store: with update-ca-certificates on the Debian family and SUSE, and with update-ca-trust on the others. Alpine reports skipped. A CA that osapi deployed already with the same content does not change and reports changed: false. A file of that name that osapi did not write is refused. macOS reports skipped. |
| HTTP | POST |
| Route | /api/node/{hostname}/certificate |
| Permission | certificate:write |
| Command | osapi client node certificate create |
| Input type | CreateInput |
| Output type | Result |
Input (2)
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|---|---|---|---|
| name | string | yes | pattern ^[a-zA-Z0-9_-]+$ | The name of the CA, such as internal-ca, which osapi writes as osapi-internal-ca.crt |
| object | string | yes | min length 1 | The object of the Object Store that has the PEM of the CA, as osapi client file upload stored it |
Output (2)
| FIELD | TYPE | DESCRIPTION |
|---|---|---|
| name | string | The CA |
| changed | boolean | Whether the host changed |
Examples (4)
| EXAMPLE | INPUT | OUTPUT |
|---|---|---|
| Add a CA | name=internal-ca, object=internal-ca.pem | name=internal-ca, changed=true |
| Add a CA on the RHEL family | name=internal-ca, object=internal-ca.pem | name=internal-ca, changed=true |
| Add a CA on SUSE | name=internal-ca, object=internal-ca.pem | name=internal-ca, changed=true |
| A CA that osapi deployed with the same content | name=internal-ca, object=internal-ca.pem | name=internal-ca, changed=false |
Method update
| Name | update |
| Verb | write |
| Description | Write a certificate authority that osapi deployed again |
| Detail | Writes the CA from the object, or from the one that it was deployed from when the object is empty, and rebuilds the trust store when the file changed. A CA that osapi did not deploy is not found. macOS reports skipped. |
| HTTP | PUT |
| Route | /api/node/{hostname}/certificate/{name} |
| Permission | certificate:write |
| Command | osapi client node certificate update |
| Input type | UpdateInput |
| Output type | Result |
Input (2)
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|---|---|---|---|
| name | string | yes | pattern ^[a-zA-Z0-9_-]+$ | The CA that osapi deployed, such as internal-ca |
| object | string | no | min length 1 | The object that has the PEM; the one it was deployed from when empty |
Output (2)
| FIELD | TYPE | DESCRIPTION |
|---|---|---|
| name | string | The CA |
| changed | boolean | Whether the host changed |
Examples (4)
| EXAMPLE | INPUT | OUTPUT |
|---|---|---|
| Write a CA from a new object | name=internal-ca, object=internal-ca-2.pem | name=internal-ca, changed=true |
| Write a CA from a new object on the RHEL family | name=internal-ca, object=internal-ca-2.pem | name=internal-ca, changed=true |
| Write a CA from a new object on SUSE | name=internal-ca, object=internal-ca-2.pem | name=internal-ca, changed=true |
| The object that it was deployed from | name=internal-ca | name=internal-ca, changed=false |
Method delete
| Name | delete |
| Verb | write |
| Description | Remove a certificate authority that osapi deployed |
| Detail | Removes the file of the CA and rebuilds the trust store: with update-ca-certificates --fresh on the Debian family and SUSE, which removes the links of the CA from /etc/ssl/certs, and update-ca-trust on the RHEL family. A CA that osapi did not deploy does not change and reports changed: false: a system CA is not osapi's to remove. macOS reports skipped. |
| HTTP | DELETE |
| Route | /api/node/{hostname}/certificate/{name} |
| Permission | certificate:write |
| Command | osapi client node certificate delete |
| Input type | DeleteInput |
| Output type | Result |
Input (1)
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|---|---|---|---|
| name | string | yes | pattern ^[a-zA-Z0-9_-]+$ | The CA that osapi deployed, such as internal-ca |
Output (2)
| FIELD | TYPE | DESCRIPTION |
|---|---|---|
| name | string | The CA |
| changed | boolean | Whether the host changed |
Examples (4)
| EXAMPLE | INPUT | OUTPUT |
|---|---|---|
| Remove a CA | name=internal-ca | name=internal-ca, changed=true |
| Remove a CA on the RHEL family | name=internal-ca | name=internal-ca, changed=true |
| Remove a CA on SUSE | name=internal-ca | name=internal-ca, changed=true |
| A CA that osapi did not deploy | name=internal-ca | name=internal-ca, changed=false |