Skip to content

fix(state-machine): reconcile abandoned TLS provisioning identities - #3046

Draft
Rashika-Rajaraman wants to merge 5 commits into
fix/serialize-device-provisioningfrom
fix/3045-interrupted-tls-cleanup
Draft

Rashika-Rajaraman wants to merge 5 commits into
fix/serialize-device-provisioningfrom
fix/3045-interrupted-tls-cleanup

Conversation

@Rashika-Rajaraman

@Rashika-Rajaraman Rashika-Rajaraman commented Nov 20, 2026 •

Copy link
Copy Markdown

Changes

Interrupted TLS provisioning can install a certificate and key on AMT before RPS saves the issued identity. A later activation can recover successfully while leaving those objects behind. This change records ownership before certificate installation and removes confirmed abandoned objects after the replacement identity is persisted and verified.

  • Keep targeted cleanup in unconfiguration.ts, sharing certificate/key deletion helpers with ordinary unconfiguration.
  • Record pending certificates using conditional Vault writes under lowercase UUID paths, matching the provisioning lock across mixed-case interruption/recovery requests. Carry cancellation into ownership writes and drain submitted journal writes before releasing the provisioning lock. Preserve active identities, trusted roots, read-only certificates, unknown objects, shared keys and valid credential associations.
  • Read complete, paginated certificate/key and TLS, AMT and IPS wired 802.1X, CIM/Wi-Fi and remote-access association inventories before selecting objects. Delete abandoned certificates before their keys, and refresh inventory after each deletion.
  • Handle AMT HTTP 401 challenges through the shared digest-authentication actor, then retry the interrupted inventory page or deletion with the refreshed challenge. Stop after three unsuccessful authentication attempts and retain pending ownership for later recovery.
  • Verify replacements against installed trusted roots or the configured issuance chain in TLS/<profile>, including intermediate CAs. Microsoft CA roots need not be installed on AMT. Without a trusted chain, preserve abandoned objects; invalid signatures block cleanup.
  • Follow the resolved activation route when deciding whether to reconcile TLS objects. An AMT 18 activation without --tls-tunnel preserves the pending journal even if its profile has a TLS mode configured and deactivation removed device credentials. TLS flows still require a persisted replacement.
  • Keep ownership records on failures so later recovery can handle interrupted deletion and lost responses. Retire completed records so future rotations cannot target completed identities. Report persistence/cleanup failures without deactivating the usable device.
  • Use one deletion actor and one journal-retirement path, centralized failure reporting and certificate/key decoding cached within each fresh inventory check.

Closes #3045.

Validation

  • 1,490 tests across 109 files passed on the complete stack using npm run test:ci on Node 22 and Node 24.22.3. Coverage includes interrupted provisioning/recovery, protected associations and shared keys, pagination, failed/lost deletion responses, persistence failures, Microsoft CA and intermediate chains, invalid signatures, non-TLS activation with a TLS-enabled profile, missing persisted identities on TLS routes, mixed-case UUID recovery, digest challenges during paginated inventory/deletion, bounded authentication failure/recovery, and provider compatibility.
  • Build, lint, formatting and git diff --check passed.
  • Two earlier AMT 21 interruption/recovery cycles succeeded without deactivation between interruption and recovery. Both returned to 2 certificates, 1 key and an empty pending journal, preserving the root and active identity. The device was deactivated between cycles. Hardware has not been rerun on the main-based revision or review fixes.

Review notes

This is PR 2 of 2, stacked on #3047: serialize provisioning per device UUID. Review #3047 first; this diff contains only the additional orphan-cleanup changes and capability checks. Coordination is required so cleanup cannot select credentials belonging to another live activation.

Cleanup requires conditional ownership writes and the prerequisite's per-UUID serialization. Providers lacking either capability continue ordinary provisioning and preserve pending objects. Untracked objects and keys created before ownership recording are preserved. Vault requires read/create/update access to tls-provisioning/<lowercase-uuid>.

The PR remains draft for review and hardware testing. Alternate firmware/provisioning routes and interruption between certificate/key deletion remain hardware integration checks. Raw logs and credentials are not included. Nothing has been deployed.

PR Checklist

  • Unit Tests have been added for new changes
  • API tests have been updated if applicable (no REST API changes)
  • All commented code has been removed
  • If a dependency was added, its license was checked (no dependencies added)

@Rashika-Rajaraman
Rashika-Rajaraman force-pushed the fix/3045-interrupted-tls-cleanup branch from 35c3429 to 798bf05 Compare November 20, 2026 09:29
@Rashika-Rajaraman
Rashika-Rajaraman changed the base branch from fix/2935 to main November 20, 2026 09:30
@Rashika-Rajaraman
Rashika-Rajaraman requested a balanced review from Copilot November 20, 2026 09:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Cleanup can reject valid Microsoft CA or intermediate-issued certificates and delete certificates or keys belonging to another live activation for the same UUID.

2 open issues
What changed in this PR

Adds recovery handling for TLS identities left by interrupted Intel AMT provisioning, addressing #3045 through the existing activation and unconfiguration state machines.

Changes:

  • Records pending certificates before installation using conditional Vault writes.
  • Adds inventory-driven cleanup after replacement persistence and verification, deleting abandoned certificates before their keys.
  • Expands recovery regression tests and shares certificate decoding across supported encodings.
File Description
src/​utils/​certHelpers.ts Extracts shared PEM and base64 DER certificate decoding.
src/​stateMachines/​unconfiguration.ts Adds targeted TLS reconciliation and shared deletion helpers.
src/​stateMachines/​unconfiguration.test.ts Tests interrupted provisioning, protected objects, pagination, and recovery failures.
src/​stateMachines/​tlsProvisioningJournal.ts Adds durable certificate ownership journal operations.
src/​stateMachines/​tls.ts Separates certificate preparation, ownership recording, and installation.
src/​stateMachines/​tls.test.ts Updates tests for the new provisioning states.
src/​stateMachines/​activation.ts Integrates reconciliation and reports persistence or cleanup failures without deactivation.
src/​stateMachines/​activation.test.ts Tests reconciliation routing and failure handling.
src/​secrets/​vault/​index.ts Implements conditional journal writes using Vault versions.
src/​secrets/​vault/​index.test.ts Verifies conditional-write request options.
src/​interfaces/​ISecretManagerService.ts Defines journal data and optional conditional-write support.

Review effort: Balanced

Comment thread src/stateMachines/unconfiguration.ts Resolved
Comment thread src/stateMachines/unconfiguration.ts Resolved
@Rashika-Rajaraman
Rashika-Rajaraman force-pushed the fix/3045-interrupted-tls-cleanup branch from a704693 to 034663c Compare November 20, 2026 10:45
@Rashika-Rajaraman
Rashika-Rajaraman changed the base branch from main to fix/serialize-device-provisioning November 20, 2026 10:45
@Rashika-Rajaraman
Rashika-Rajaraman requested a balanced review from Copilot November 20, 2026 10:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The cleanup inventory can delete certificates and keys still used by wired 802.1X, and retained journals can cause false activation errors after successful non-TLS provisioning.

3 open issues
1 resolved since last review

Review effort: Balanced

Comment thread src/stateMachines/unconfiguration.ts Resolved
Comment thread src/stateMachines/unconfiguration.ts Resolved
@Rashika-Rajaraman
Rashika-Rajaraman force-pushed the fix/3045-interrupted-tls-cleanup branch 3 times, most recently from 7511f90 to d2ecd4c Compare November 20, 2026 11:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

UUID casing mismatches can leave abandoned certificates and keys behind during recovery, and unhandled WS-Man 401 challenges can abort reconciliation despite valid credentials.

2 open issues
3 resolved since last review

Review effort: Balanced

Comment thread src/stateMachines/unconfiguration.ts Resolved
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.

Interrupted TLS provisioning leaves an unused certificate and key pair after recovery

2 participants