Surface SCEP failures that are proxied by Fleet (Windows)
Goal
| User story |
|---|
| As a Fleet admin proxying Windows SCEP cert issuance through Fleet, |
| I want to see when a host's SCEP exchange fails at the upstream CA |
| so that I can diagnose the failure instead of seeing the profile incorrectly reported as "Verified" while the host has no cert. |
Demo: https://www.youtube.com/watch?v=WNGuFdeBmzA Docs: https://github.com/fleetdm/fleet/pull/48933/changes
Background
When Fleet acts as the SCEP proxy for a Windows MDM profile (via
$FLEET_VAR_CUSTOM_SCEP_PROXY_URL_<CA>, $FLEET_VAR_NDES_SCEP_PROXY_URL), Fleet has direct visibility into upstream SCEP errors but does not surface them. (Note: Smallstep CA is not supported in Windows #48925) Today:
- The Windows MDM CSP for
ClientCertificateInstall/SCEP/.../Install/EnrollACKs its<Exec>with SyncML Status200immediately, then runs the SCEP exchange asynchronously. - Fleet's SCEP proxy wraps and returns upstream errors but persists nothing. No
host_mdm_windows_profiles.statusupdate, no activity, no audit trail. - Net result:
host_mdm_windows_profiles.status = 'verified'for hosts that never got a cert.
Empirical results on real Windows 11
Timing confirms async semantics:
- Device received the SCEP profile commands at 01:55:02
- Device responded to Fleet at 01:55:02 with Atomic=200, all Add=200, Exec(/Install/Enroll)=202
- SCEP CSP ran the actual exchange immediately after, failed at DNS lookup (0x80072ee7 WININET_E_NAME_NOT_RESOLVED) — logged in the Windows event log
- No com.microsoft:mdm.SCEP Alert in the next 5+ minutes of sync activity. (Whether Windows ever emits it depends on CSP version; even if it does, Fleet's processGenericAlert would drop it.)
Fleet's view, unchanged after the device confirmed the SCEP failure: windows_mdm_command_results.status_code = 200 host_mdm_windows_profiles.status = 'verified' host_mdm_windows_profiles.detail = '' host_mdm_windows_profiles.retries = 0
Scope
Primary: Windows profiles whose SCEP ServerURL is one of Fleet's *_SCEP_PROXY_URL_*
variables. When the upstream CA returns an error during PKIOperation, Fleet must mark the corresponding host_mdm_windows_profiles row as failed with a meaningful detail.
Changes
Product
- [ ] UI changes: profile detail and host profile listings surface "Failed" with the SCEP upstream error reason when the proxy detects an upstream failure. No new screens. Figma cover page.
- [ ] CLI (fleetctl) usage changes: No changes.
- [ ] YAML changes: No changes.
- [ ] REST API changes: No changes.
- [ ] Fleet's agent (fleetd) changes: No changes.
- [ ] Fleet server configuration changes: No changes.
- [ ] Exposed, public API endpoint changes: No changes.
- [ ] fleetdm.com changes: No changes.
- [ ] GitOps mode UI changes: No changes.
- [ ] GitOps generation changes: No changes.
- [ ] Activity changes: No changes.
- [ ] Permissions changes: No changes.
- [ ] Changes to paid features or tiers: No changes. SCEP proxy is already Fleet Premium; this is an improvement to an existing premium feature.
- [ ] My device and fleetdm.com/better changes: No changes.
- [ ] Usage statistics: No changes.
- [ ] Other reference documentation changes: No changes.
- [ ] First draft of test plan added
- [ ] Once shipped, requester has been notified
- [ ] Once shipped, dogfooding issue has been filed
Engineering
- [ ] Test plan is finalized
- [ ] Contributor API changes: No changes.
- [ ] Feature guide changes: update the SCEP/cert proxy guide to mention how failures are reported now.
- [ ] Database schema migrations: None expected. Reuses existing
host_mdm_windows_profilescolumns (status,detail,retries). - [ ] Load testing: None required. Failure path runs at the same per-host rate as cert issuance.
- [ ] Pre-QA load test: Not required.
- [ ] Load testing/osquery-perf improvements: Optional follow-up: extend osquery-perf to simulate SCEP proxy failures (delay or HTTP error injection) so the failure path can be exercised at scale during CI/perf testing.
- [ ] This is a premium only feature: Yes (SCEP proxy is premium). Confirm both frontend and backend gating.
ℹ️ Please read this issue carefully and understand it. Pay special attention to UI wireframes, especially "dev notes".
Risk assessment
- Requires testing in a hosted environment: No. Local
micromdm/scepwith a delay/error proxy is sufficient. - Requires load testing: No.
- Risk level: Low
Test plan
Make sure to go through the list and consider all events that might be related to this story, so we catch edge cases earlier.
Setup
- [x] Run
micromdm/sceplocally with a Go reverse-proxy in front that can return arbitrary HTTP status or sleep on demand (via a query string or env var). - [x] Configure a Custom SCEP CA in Fleet pointing at the reverse proxy.
- [x] Upload a Windows SCEP profile that uses
$FLEET_VAR_CUSTOM_SCEP_PROXY_URL_<CA>and$FLEET_VAR_CUSTOM_SCEP_CHALLENGE_<CA>. - [x] Enroll a Windows host.
Core flow
- [x] Healthy upstream: profile transitions through Pending → Verifying → Verified;
host_mdm_managed_certificatesrow is written; certificate present on host. - [x] Upstream returns 500 on
PKIOperation: profile transitions to Failed - [x] Upstream timeout (>30s) on
PKIOperation: profile transitions to Failed; detail mentionstimeout - [x] Try other types of errors.
UI
- [x] Host detail page shows the affected profile as "Failed" with the SCEP error detail.
- [x] Profile summary on the Hosts list / dashboard reflects the failure count.
- [x] Verify expected UI states (loading, empty, error states if applicable).
API
- [x]
GET /api/v1/fleet/hosts/{id}returns the affected profile withstatus: "failed"and adetailstring describing the SCEP operation and classified upstream error. - [x] Verify error handling for invalid inputs where applicable (e.g., proxy URL pointing at a host that doesn't accept connections; profile UUID mismatch).
GitOps (generate + run)
- [x] Configure the Custom SCEP CA + profile through the UI and run
fleetctl generate-gitops. - [x] Confirm the generated
.ymlincludes the expected fields (CA config, profile body). - [x] Modify the generated
.ymland runfleetctl gitops. - [x] Confirm the configuration updates correctly in Fleet.
- [x] Enable GitOps mode and verify the feature behaves correctly (read-only profile view still shows Failed state for hosts that experienced SCEP failures).
Permissions
- [x] Verify role restrictions are applied correctly for global roles (admin, maintainer, observer, observer+, gitops). Failure detail visibility should match existing profile status visibility rules.
- [x] Verify role restrictions are applied correctly for fleet-level roles.
Edge cases
- [x] Concurrent failure on many hosts (100+ simultaneously): no DB deadlocks; each row updates independently; resend cron handles all failures in subsequent ticks.
- [x] Upstream recovers after permanent-failure marking: profile manually resent via UI / API succeeds and transitions to Verified.
- [x] Fleet challenge consumed AND upstream returns an error on the same request: the existing
challenge-validation resend path takes precedence; no
double-write to
host_mdm_windows_profiles. - [x] Profile is removed while a SCEP exchange is in flight: the failure write must not resurrect a row that was just deleted.
- [x] Mixing of healthy and failing CAs in the same Fleet instance: failures must be scoped to
the specific
(host, profile, ca_name)and not affect unrelated profiles.
Supplemental testing
Testing notes
- A throwaway Go reverse-proxy script for fault injection is useful for QA.
Confirmation
- [x] Engineer: Added comment to user story confirming successful completion of test plan (include any special setup, test data, or configuration used during development/testing if applicable).
- [x] QA: Added comment to user story confirming successful completion of test plan.
- [ ] QA: Determined whether this story needs Playwright automation.
- Needs automation: Yes / No
- If yes, filed a follow-up issue in the :help-qa project with status "Needs automation": TODO
@sharon-fdm @mostlikelee Do y'all have capacity next sprint for this? It's currently assigned to us with assisting but we've got a pretty full plate.
@lukeheath , looks like 4.88.0 is heavy for S&C.
We may push things a bit to make it work. I can chat with @rachaelshaw in today's standup and answer better.
@sharon-fdm Okay on re-review we can take it if S&C can't.
@lukeheath, we'll need to do some shuffling in order to take it. If y'all are on it, it's great. Let me know, please.
Test plan complete
QA approves, looks great!
Notified customer-numa. Closing
Clouds catch upstream rain Admins see where certs failed trust flows through clearly