Skip to main content

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​

Namecertificate
DescriptionThe certificate authorities that the host trusts
Placementnode
Areasecurity
Internalno
APIyes
CLIyes
Nextno
Platformsdebian, suse, linux, darwin
Sudoupdate-ca-certificates, update-ca-trust
Runsnone
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 stateno
Usesobject, managedfile
Used bynone

Methods (5)​

NAMEVERBHTTPROUTEPERMISSIONDESCRIPTION
listreadGET/api/node/{hostname}/certificatecertificate:readList the certificate authorities that the host trusts
getreadGET/api/node/{hostname}/certificate/{name}certificate:readGet one certificate authority
createwritePOST/api/node/{hostname}/certificatecertificate:writeAdd a certificate authority to the trust store
updatewritePUT/api/node/{hostname}/certificate/{name}certificate:writeWrite a certificate authority that osapi deployed again
deletewriteDELETE/api/node/{hostname}/certificate/{name}certificate:writeRemove a certificate authority that osapi deployed

Types (5)​

NAMEINPUTOUTPUT
listListInput[]Entry { name, path, source, enabled, subject, fingerprint, not_after, managed, object }
getGetInput { name* }Entry { name, path, source, enabled, subject, fingerprint, not_after, managed, object }
createCreateInput { name*, object* }Result { name, changed }
updateUpdateInput { name*, object }Result { name, changed }
deleteDeleteInput { name* }Result { name, changed }

Settings (0)​

None. Declare them with behavior.Config.

Telemetry​

Spanbehavior.certificate.<method>
Child spansbehavior.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
Metricsosapi_behavior_calls_total, osapi_behavior_duration_seconds, osapi_behavior_changes_total
Attributesosapi.behavior.name, osapi.behavior.method, osapi.behavior.verb, osapi.behavior.outcome, osapi.behavior.changed
Recorded inputsname (get, create, update, delete)

Method list​

Namelist
Verbread
DescriptionList the certificate authorities that the host trusts
DetailLists 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.
HTTPGET
Route/api/node/{hostname}/certificate
Permissioncertificate:read
Commandosapi client node certificate list
Input typeListInput
Output type[]Entry

Input (0)​

None. The method takes no input; its command needs only --target.

Output (9)​

FIELDTYPEDESCRIPTION
namestringThe CA: the name it was deployed with for a CA that osapi deployed, else its file's name
pathstringThe file, or on macOS the keychain, that has it
sourcestringsystem for a CA of the distribution, local for one an administrator added
enabledbooleanWhether the host trusts it: false for a system CA that the trust store turns off
subjectstringIts subject, such as CN=ISRG Root X1,O=Internet Security Research Group,C=US
fingerprintstringThe SHA-256 of the certificate, in hex
not_afterstringWhen it expires
managedbooleanWhether osapi deployed it, and its writes change it
objectstringThe object that osapi deployed it from

Examples (5)​

EXAMPLEINPUTOUTPUT
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​

Nameget
Verbread
DescriptionGet one certificate authority
DetailReads 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.
HTTPGET
Route/api/node/{hostname}/certificate/{name}
Permissioncertificate:read
Commandosapi client node certificate get
Input typeGetInput
Output typeEntry

Input (1)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
namestringyespattern ^[^/%\x00-\x1f\x7f]+$, max length 255The 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)​

FIELDTYPEDESCRIPTION
namestringThe CA: the name it was deployed with for a CA that osapi deployed, else its file's name
pathstringThe file, or on macOS the keychain, that has it
sourcestringsystem for a CA of the distribution, local for one an administrator added
enabledbooleanWhether the host trusts it: false for a system CA that the trust store turns off
subjectstringIts subject, such as CN=ISRG Root X1,O=Internet Security Research Group,C=US
fingerprintstringThe SHA-256 of the certificate, in hex
not_afterstringWhen it expires
managedbooleanWhether osapi deployed it, and its writes change it
objectstringThe object that osapi deployed it from

Examples (4)​

EXAMPLEINPUTOUTPUT
A CA that osapi deployed, by the name it was deployed withname=internal-caname=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 familyname=internal-caname=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 SUSEname=internal-caname=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 Macname=osapi example CAname=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​

Namecreate
Verbwrite
DescriptionAdd a certificate authority to the trust store
DetailWrites 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.
HTTPPOST
Route/api/node/{hostname}/certificate
Permissioncertificate:write
Commandosapi client node certificate create
Input typeCreateInput
Output typeResult

Input (2)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
namestringyespattern ^[a-zA-Z0-9_-]+$The name of the CA, such as internal-ca, which osapi writes as osapi-internal-ca.crt
objectstringyesmin length 1The object of the Object Store that has the PEM of the CA, as osapi client file upload stored it

Output (2)​

FIELDTYPEDESCRIPTION
namestringThe CA
changedbooleanWhether the host changed

Examples (4)​

EXAMPLEINPUTOUTPUT
Add a CAname=internal-ca, object=internal-ca.pemname=internal-ca, changed=true
Add a CA on the RHEL familyname=internal-ca, object=internal-ca.pemname=internal-ca, changed=true
Add a CA on SUSEname=internal-ca, object=internal-ca.pemname=internal-ca, changed=true
A CA that osapi deployed with the same contentname=internal-ca, object=internal-ca.pemname=internal-ca, changed=false

Method update​

Nameupdate
Verbwrite
DescriptionWrite a certificate authority that osapi deployed again
DetailWrites 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.
HTTPPUT
Route/api/node/{hostname}/certificate/{name}
Permissioncertificate:write
Commandosapi client node certificate update
Input typeUpdateInput
Output typeResult

Input (2)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
namestringyespattern ^[a-zA-Z0-9_-]+$The CA that osapi deployed, such as internal-ca
objectstringnomin length 1The object that has the PEM; the one it was deployed from when empty

Output (2)​

FIELDTYPEDESCRIPTION
namestringThe CA
changedbooleanWhether the host changed

Examples (4)​

EXAMPLEINPUTOUTPUT
Write a CA from a new objectname=internal-ca, object=internal-ca-2.pemname=internal-ca, changed=true
Write a CA from a new object on the RHEL familyname=internal-ca, object=internal-ca-2.pemname=internal-ca, changed=true
Write a CA from a new object on SUSEname=internal-ca, object=internal-ca-2.pemname=internal-ca, changed=true
The object that it was deployed fromname=internal-caname=internal-ca, changed=false

Method delete​

Namedelete
Verbwrite
DescriptionRemove a certificate authority that osapi deployed
DetailRemoves 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.
HTTPDELETE
Route/api/node/{hostname}/certificate/{name}
Permissioncertificate:write
Commandosapi client node certificate delete
Input typeDeleteInput
Output typeResult

Input (1)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
namestringyespattern ^[a-zA-Z0-9_-]+$The CA that osapi deployed, such as internal-ca

Output (2)​

FIELDTYPEDESCRIPTION
namestringThe CA
changedbooleanWhether the host changed

Examples (4)​

EXAMPLEINPUTOUTPUT
Remove a CAname=internal-caname=internal-ca, changed=true
Remove a CA on the RHEL familyname=internal-caname=internal-ca, changed=true
Remove a CA on SUSEname=internal-caname=internal-ca, changed=true
A CA that osapi did not deployname=internal-caname=internal-ca, changed=false