Skip to content

fix(windows): import WireServer certs into trust stores - #9353

Merged
Sylvain Boily (djsly) merged 3 commits into
mainfrom
rchinchani/import-wireserver-certs-to-system-trust
Sep 1, 2026
Merged

fix(windows): import WireServer certs into trust stores#9353
Sylvain Boily (djsly) merged 3 commits into
mainfrom
rchinchani/import-wireserver-certs-to-system-trust

Conversation

@rchincha

Copy link
Copy Markdown
Contributor

Install certificates downloaded by Get-CACertificates into the LocalMachine certificate stores instead of leaving them only under C:\ca. Legacy endpoint certificates and rcv1p root certificates are added to the Root store, while rcv1p intermediate certificates are added to the CA store to preserve the correct trust-chain semantics.

Use ErrorAction Stop so import failures follow the existing Get-CACertificates error handling and fail provisioning when FailOnError is requested. Extend the focused Pester coverage to verify the file paths, destination stores, and terminating error behavior passed to Import-Certificate.

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Install certificates downloaded by Get-CACertificates into the LocalMachine certificate stores instead of leaving them only under C:\ca. Legacy endpoint certificates and rcv1p root certificates are added to the Root store, while rcv1p intermediate certificates are added to the CA store to preserve the correct trust-chain semantics.

Use ErrorAction Stop so import failures follow the existing Get-CACertificates error handling and fail provisioning when FailOnError is requested. Extend the focused Pester coverage to verify the file paths, destination stores, and terminating error behavior passed to Import-Certificate.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Windows Unit Test Results

  3 files   13 suites   51s ⏱️
406 tests 406 ✅ 0 💤 0 ❌
409 runs  409 ✅ 0 💤 0 ❌

Results for commit 4092b42.

♻️ This comment has been updated with latest results.

Copilot AI left a comment

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.

Pull request overview

Imports WireServer certificates into Windows LocalMachine trust stores.

Changes:

  • Imports legacy/root certificates into Root.
  • Imports intermediate certificates into CA.
  • Adds Pester assertions for paths, stores, and error behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
staging/cse/windows/kubernetesfunc.ps1 Adds certificate-store imports.
staging/cse/windows/kubernetesfunc.tests.ps1 Tests import parameters.
Suppressed comments (1)

staging/cse/windows/kubernetesfunc.ps1:450

  • 🔴 High Risk — 🔧 Script Logic: This rcv1p path has the same Windows PowerShell 5.1 encoding problem: > serializes the response string as UTF-16LE, then the newly added import attempts to parse it as a certificate. Use an explicit ASCII/UTF-8 write so root and intermediate imports receive valid PEM/base64 bytes.
                Import-Certificate -FilePath $certFilePath -CertStoreLocation $certStoreLocation -ErrorAction Stop | Out-Null

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread staging/cse/windows/kubernetesfunc.ps1 Outdated
Comment thread staging/cse/windows/kubernetesfunc.tests.ps1
Write legacy and rcv1p WireServer certificate bodies with explicit ASCII encoding before passing them to Import-Certificate. This prevents Windows PowerShell 5.1 redirection from producing UTF-16LE files that the certificate parser cannot import.

Strengthen unit coverage with byte-level encoding assertions and update the Windows rcv1p e2e validator to parse each downloaded certificate and verify its thumbprint exists in the LocalMachine Root or CA store.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

staging/cse/windows/kubernetesfunc.ps1:451

  • 🟡 Medium Risk — Any rcv1p import failure is handled by the function-level catch as Failed to retrieve CA certificates (HTTP N/A), even though retrieval succeeded. This makes certificate parsing and LocalMachine store failures appear to be network failures in CSE diagnostics. Preserve import-stage context or make the shared error message cover both retrieval and installation.
                Import-Certificate -FilePath $certFilePath -CertStoreLocation $certStoreLocation -ErrorAction Stop | Out-Null

Comment thread staging/cse/windows/kubernetesfunc.ps1 Outdated
Wrap each WireServer certificate import with certificate and destination-store context so malformed input and certificate-store permission failures are actionable during provisioning.

Rename the shared failure message from retrieval to processing because the handler covers download, parsing, file writing, and trust-store import. Add focused Pester coverage for both retrieval and import diagnostics.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 1, 2026 00:57

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

$downloadedAny = $false

foreach ($requestType in $operationRequestTypes) {
# Keep intermediates out of the trusted root store while making both chains system-wide.

@timmy-wright Tim Wright (timmy-wright) Sep 1, 2026

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.

How does this keep intermediates out of the trusted root store?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Wireserver returns both root certs and intermediate certs

In Windows, the following is true (iinm):

Root store: Cert:\LocalMachine\Root (Trusted Root Certification Authorities)

Intermediate store: Cert:\LocalMachine\CA (Intermediate Certification Authorities)

So intermediate certs are kept of out Cert:\LocalMachine\Root

That's all the comment is indicating.

@rchincha

Copy link
Copy Markdown
Contributor Author

There appears to be a legitimate e2e failure.
Please DON'T MERGE until I root cause it.

@rchincha
Ramkumar Chinchani (rchincha) marked this pull request as draft September 1, 2026 14:22
@rchincha
Ramkumar Chinchani (rchincha) marked this pull request as ready for review September 1, 2026 18:49
@rchincha

Ramkumar Chinchani (rchincha) commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

There appears to be a legitimate e2e failure. Please DON'T MERGE until I root cause it.

After turning on KEEP_VMSS=true, logs show the cert import is fine and the kubelet error is due to the issue the following PR is trying to fix
#9356
https://msazure.visualstudio.com/CloudNativeCompute/_build/results?buildId=179094350&view=results

@djsly
Sylvain Boily (djsly) enabled auto-merge (squash) September 1, 2026 19:25
@djsly
Sylvain Boily (djsly) merged commit 8cf122a into main Sep 1, 2026
36 checks passed
@djsly
Sylvain Boily (djsly) deleted the rchinchani/import-wireserver-certs-to-system-trust branch September 1, 2026 22:48
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.

4 participants