fix(windows): import WireServer certs into trust stores - #9353
Conversation
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>
Windows Unit Test Results 3 files 13 suites 51s ⏱️ Results for commit 4092b42. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
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.
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>
There was a problem hiding this comment.
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
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>
| $downloadedAny = $false | ||
|
|
||
| foreach ($requestType in $operationRequestTypes) { | ||
| # Keep intermediates out of the trusted root store while making both chains system-wide. |
There was a problem hiding this comment.
How does this keep intermediates out of the trusted root store?
There was a problem hiding this comment.
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.
|
There appears to be a legitimate e2e failure. |
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 |
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 #