Skip to content

[YAML/API] Deploy certificates on Android hosts via GitOps - #35270

Merged
rachaelshaw merged 16 commits into
docs-v4.78.0from
35198-yaml-changes
Dec 19, 2025
Merged

[YAML/API] Deploy certificates on Android hosts via GitOps #35270
rachaelshaw merged 16 commits into
docs-v4.78.0from
35198-yaml-changes

Conversation

@marko-lisica

Copy link
Copy Markdown
Member

Added certificates section under android_settings with details on certificate name, authority, and subject name.
@marko-lisica marko-lisica changed the title [YAML] Deploy certificates on Android hosts via GitOps [YAML/API] Deploy certificates on Android hosts via GitOps Nov 6, 2025
- name: wifi-certificate
certificate_authority_name: EST_WIFI
subject_name: /CN=$FLEET_VAR_HOST_END_USER_IDP_USERNAME/OU=$FLEET_VAR_HOST_UUID/ST=$FLEET_VAR_HOST_HARDWARE_SERIAL
macos_setup: # Available in Fleet Premium

@marko-lisica marko-lisica Nov 6, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dev note:


Errors:

  • If user specified name that is already taken by another certificate:
    • Couldn't edit "<file_name>" at "<full_path>": "<cert_name>" name is already used by another certificate. Please choose a different name and try again.
  • If the user specified name with characters that are not supported:
    • Couldn't edit "<file_name>" at "<full_path>": Invalid characters in "name" field. Only letters, numbers, spaces, dashes, and underscores allowed.
  • If the user didn't specify the required field:
    • Couldn't edit "<file_name>" at "<full_path>": "<field_name>" is required.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marko-lisica If user specified invalid Fleet variable, like $FLEET_VAR_BOZO?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marko-lisica If user specified $FLEET_SECRET_SOMETHING?

@marko-lisica marko-lisica Nov 24, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@getvictor If IdP variable is empty, we should return an error on the host details on the OS settings modal. I think we should be consistent with any invalid variable and secret.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If user specify CA other than custom SCEP proxy, throw an error:

Couldn't edit "<file_name>" at "<full_path>": Currently, only the custom_scep_proxy` certificate authority is supported.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marko-lisica What about these:

  • If user specified invalid Fleet variable, like $FLEET_VAR_BOZO?
  • If user specified $FLEET_SECRET_SOMETHING?

@marko-lisica marko-lisica Dec 8, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@getvictor What do we do for configuration profiles in that case? We should do the same.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marko-lisica configuration profiles support secrets, while the Android certificates do not (we do not have secrets support coded).

configuration profiles return an error on unsupported Fleet variables.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's show this error message if variable is not supported or doesn't exist:

Couldn’t add. Variable "$FLEET_VAR_BOZO" doesn’t exist.

For secrets:

Couldn’t add. Secret variables (prefixed with "$FLEET_SCERET_") are not supported in the certificates.

Comment thread docs/REST API/rest-api.md Outdated
Comment thread docs/REST API/rest-api.md Outdated
Comment thread docs/REST API/rest-api.md Outdated
Comment thread docs/REST API/rest-api.md

@rachaelshaw rachaelshaw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marko-lisica LGTM, other than pending review comments! Will approve once those are addressed

Co-authored-by: Noah Talerman <47070608+noahtalerman@users.noreply.github.com>
Comment thread docs/REST API/rest-api.md Outdated
Comment thread docs/REST API/rest-api.md Outdated
@marko-lisica

Copy link
Copy Markdown
Member Author

Hey @ksykulev, commenting here because this API PR is related to GitOps story that we're working on. I documented API you listed in the comment here:

Just to be specific, here are the endpoints I made as in #35788
GET /api/latest/fleet/certificates
GET /api/latest/fleet/certificates/:id
POST /api/latest/fleet/spec/certificates
DELETE /api/latest/fleet/spec/certificates

Where do we use "List certificates" (GET /api/latest/fleet/certificates)?

And a few questions re contributor endpoints:

  • Why do we need DELETE /api/latest/fleet/spec/certificates?
  • Could we use the approach we did for batch-apply scripts, software, and profiles
    • To have POST /api/latest/fleet/certificates/batch instead of /spec/certificates route. Please see this PR where I documented the batch-apply certificates endpoint.

@ksykulev

ksykulev commented Nov 20, 2025

Copy link
Copy Markdown
Contributor

@marko-lisica

Where do we use "List certificates" (GET /api/latest/fleet/certificates)?

This is used in the gitops flow. We get all the team's certificates, do a delta, delete the ones not present in the yaml and create update the ones that are. This is the way queries work for example.


## Certificates

### Batch-apply certificate templates

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ksykulev TODO change to DELETE /api/latest/fleet/certificates/

Comment thread docs/REST API/rest-api.md
Comment on lines +822 to +830
#### Request headers

This endpoint accepts the node key from Fleet's Android agent for authentication in addition to [default authentication](#retrieve-your-api-token) with a Bearer token.

The `Authorization` header must be formatted as follows:

```
Authorization: Node key <node_key>
```

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ksykulev, do we need this? Does the agent call this endpoint? If I remember correctly, we added a new contributor endpoint (/fleetd) for the agent to get cert information?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marko-lisica, the parameter for the team should be team_id instead of team, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndreyKizimenko, that's righ,t it should be team_id, that's consistent with other endpoints. Not sure if this is implemented.

Do we need this? Does the agent call this endpoint? If I remember correctly, we added a new contributor endpoint (/fleetd) for the agent to get cert information?

@ksykulev can you confirm if the agent is using this endpoint and if we support node key authentication for this endpoint?

Comment thread docs/REST API/rest-api.md

Get details of the certificate added to Fleet.

`GET /api/v1/fleet/certificates/:id`

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ksykulev, is this one used by GitOps? Did we end up implementing this one? Now, when we returnsubject_name in the list endpoint, can we remove this one?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ksykulev ping in case you missed this ^

Comment thread docs/Contributing/reference/api-for-contributors.md Outdated
| --------- | ------ | ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| specs | array | body | **Required**. An array of objects with the certificate templates. Each item must contain `name` with the certificate template name, a `team` with a team name, `certificate_authority_id` with the certificate authority id, and `subject_name` with the certificate's subject name. |

> Any existing certificate template that is not included in the list will be removed, and existing templates with the same name as the new template will be edited. Providing an empty list of certificate templates will remove existing scripts.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> Any existing certificate template that is not included in the list will be removed, and existing templates with the same name as the new template will be edited. Providing an empty list of certificate templates will remove existing scripts.
> Any existing certificate template that is not included in the list will be removed, and existing templates with the same name as the new template will be edited. Providing an empty list of certificate templates will remove existing templates.

I think "scripts" might have been a typo? Or are there scripts involved? cc @marko-lisica

(Will approve anyway since this is a contributor endpoint)

@rachaelshaw
rachaelshaw merged commit 4d810f8 into docs-v4.78.0 Dec 19, 2025
6 checks passed
@rachaelshaw
rachaelshaw deleted the 35198-yaml-changes branch December 19, 2025 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants