Fix ACME cert not showing for user-channel profiles - #51297
Draft
sharon-fdm wants to merge 2 commits into
Draft
Conversation
Send CertificateList to the user enrollment channel when the ACME profile has PayloadScope=User, so hardware-bound certs in the user's login keychain are visible to Fleet.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #51297 +/- ##
==========================================
+ Coverage 68.65% 68.77% +0.11%
==========================================
Files 3995 4001 +6
Lines 257608 258473 +865
Branches 13806 13806
==========================================
+ Hits 176864 177766 +902
+ Misses 65015 64909 -106
- Partials 15729 15798 +69
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue: Resolves #51281
Checklist for submitter
What
ACME certificates deployed via user-scoped profiles on macOS are not showing on the host details page.
How it was reproduced
Integration test (
TestACMECertNotShowingForUserChannelProfile) against a real Fleet server + MySQL:PayloadScope=User)InstallProfileon the user channelCertificateListis queued to the device channel (host UUID). The device channel only sees system-keychain certs, but user-scoped ACME certs land in the user's login keychain. Result: cert is invisible to Fleet.CertificateListis queued to the user channel (user enrollment ID). The user channel sees login-keychain certs. Result: cert shows up in the host certificates API.Technical description
Root cause:
maybeQueueCertificateListForACMEProfilealways sendsCertificateListtohostUUID(device channel), regardless of the profile's scope. On macOS, user-scoped profiles install ACME certs into the user's login keychain, which is only visible to the user-channelCertificateList.Fix (4 small changes):
server/fleet/mdm.go: AddScopefield toProfileACMECommandResultso the caller knows whether the profile is user-scoped or system-scoped.server/datastore/mysql/mdm.go: Selecthmap.scopeinProfileHasACMEPayloadForCommandquery.server/service/apple_mdm.go: InmaybeQueueCertificateListForACMEProfile, whenScope == User, look up the user enrollment ID viaGetNanoMDMUserEnrollmentand sendCertificateListto that enrollment instead of the device UUID.pkg/mdm/mdmtest/apple.go: AddSendRawResponsehelper to the test MDM client so integration tests can send command responses with arbitrary plist data (needed to simulateCertificateListresponses with certificate payloads).Testing
COMPOSE_FILE=docker-compose.yml MYSQL_TEST=1 MYSQL_PORT=3307 REDIS_TEST=1 go test -v -run 'TestIntegrationsMDM/TestACMECertNotShowingForUserChannelProfile' -timeout 600s ./server/service/