mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 00:49:03 +00:00
**Related issue:** Resolves #35460, #35462 # Checklist for submitter - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files) for more information. - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) ## Testing - [x] Added/updated automated tests - [x] Where appropriate, [automated tests simulate multiple hosts and test for host isolation](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/reference/patterns-backend.md#unit-testing) (updates to one hosts's records do not affect another) - [x] QA'd all new/changed functionality manually ## Database migrations - [x] Checked schema for all modified table for columns that will auto-update timestamps during migration. - [x] Confirmed that updating the timestamps is acceptable, and will not cause unwanted side effects. - [x] Ensured the correct collation is explicitly set for character columns (`COLLATE utf8mb4_unicode_ci`). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **New Features** * Added certificate templates for managing Android device certificates at global and team levels * Introduced API endpoints to create, list, retrieve, and delete certificate templates * Enabled GitOps workflow support for certificate template specifications * Implemented automatic variable substitution in certificate subjects for host identifiers <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Scott Gress <scottmgress@gmail.com> Co-authored-by: Scott Gress <scott@fleetdm.com>
31 lines
1.5 KiB
Go
31 lines
1.5 KiB
Go
package service
|
|
|
|
import "github.com/fleetdm/fleet/v4/server/fleet"
|
|
|
|
// GetCertificateAuthoritiesSpec fetches the certificate authorities stored on the server
|
|
func (c *Client) GetCertificateAuthoritiesSpec(includeSecrets bool) (*fleet.GroupedCertificateAuthorities, error) {
|
|
verb, path := "GET", "/api/latest/fleet/spec/certificate_authorities"
|
|
var responseBody getCertificateAuthoritiesSpecResponse
|
|
query := ""
|
|
if includeSecrets {
|
|
query = "include_secrets=true"
|
|
}
|
|
err := c.authenticatedRequestWithQuery(nil, verb, path, &responseBody, query)
|
|
return responseBody.CertificateAuthorities, err
|
|
}
|
|
|
|
// ApplyCertificateAuthoritiesSpec applies the certificate authorities.
|
|
func (c *Client) ApplyCertificateAuthoritiesSpec(groupedCAs fleet.GroupedCertificateAuthorities, opts fleet.ApplySpecOptions) error {
|
|
req := batchApplyCertificateAuthoritiesRequest{CertificateAuthorities: groupedCAs, DryRun: opts.DryRun}
|
|
verb, path := "POST", "/api/latest/fleet/spec/certificate_authorities"
|
|
var responseBody batchApplyCertificateAuthoritiesResponse
|
|
return c.authenticatedRequestWithQuery(req, verb, path, &responseBody, opts.RawQuery())
|
|
}
|
|
|
|
// GetCertificateAuthorities fetches the list of certificate authorities
|
|
func (c *Client) GetCertificateAuthorities() ([]*fleet.CertificateAuthoritySummary, error) {
|
|
verb, path := "GET", "/api/latest/fleet/certificate_authorities"
|
|
var responseBody listCertificateAuthoritiesResponse
|
|
err := c.authenticatedRequest(nil, verb, path, &responseBody)
|
|
return responseBody.CertificateAuthorities, err
|
|
}
|