Skip to content

[release/17.0] Pin the dev certificate in extension E2E HTTPS probes instead of disabling validation - #22043

Closed
Mitch Denny (mitchdenny) wants to merge 1 commit into
mitchdenny-backport-17-0-44-pr21642from
mitchdenny-backport-17-0-45-pr21898
Closed

Mitch Denny (mitchdenny) wants to merge 1 commit into
mitchdenny-backport-17-0-44-pr21642from
mitchdenny-backport-17-0-45-pr21898

Conversation

@mitchdenny

Copy link
Copy Markdown
Member

Description

Backport of #21898 to release/17.0 (cherry-picked from 7dc0df2 with no modifications).

Layer 45 of 55 in the release/17.0 backport stack; stacked on #22042.

Backport recommendation: No — Extension E2E tests only.

Validation: Stable patch IDs match (0843a8233826e1a5043a3f178e994e8243ba8f28). Builds/tests not run for this unchanged cherry-pick.

Backport of #21898

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

…bling validation (#21898)

## Description

CodeQL reports `js/disabling-certificate-validation` ([CodeQL.SM03616],
Critical) against `extension/src/test-e2e/helpers/assertions.ts`:
`getUrlText` passed `rejectUnauthorized: false` to `https.get`. The live
VS Code extension E2E tests use it (through `waitForHttpText`) to probe
the Dashboard and HTTPS resource endpoints of a running AppHost, which
are served with the ASP.NET Core development certificate. Clean machines
and hosted runners do not trust that certificate, so verification was
switched off for the probe.

This PR keeps verification on and trusts exactly the certificate the
AppHost serves:

- `extension/scripts/run-e2e.js` exports the public half of the
development certificate with `dotnet dev-certs https --export-path
<run-root>/aspnetcore-dev-cert.pem --format Pem` and passes the file to
the test process as `ASPIRE_EXTENSION_E2E_DEV_CERT_PATH`. The export
creates the certificate if the machine has none (as the CLI does on
first run) but never trusts it, and writes no private key (`dotnet
dev-certs` only writes one with `--password`/`--no-password`). A failed
export is a warning, not a failure, so shards that never probe HTTPS are
unaffected.
- `extension/src/test-e2e/helpers/assertions.ts` replaces
`rejectUnauthorized: false` with `ca: <exported PEM>`. Chain and host
name validation still run, any other certificate is rejected, and
without the env var the default trust store applies. No
`checkServerIdentity` override, `NODE_TLS_REJECT_UNAUTHORIZED`, or other
bypass is introduced, and the extension's own runtime behavior is
unchanged (this is test-helper and test-runner code only).
- `extension/src/test-e2e/helpers/paths.ts` gets `getDevCertPath()`.

How this removes the flagged pattern: CodeQL's query matches TLS options
that set `rejectUnauthorized: false` (or an equivalent bypass). The
helper now supplies a CA certificate to the TLS client instead, which
keeps validation enabled, so no suppression comment is needed.

### Validation

All commands were run from `extension/` on Windows (Node 22, repo-local
.NET SDK).

| Command | Result |
| --- | --- |
| `corepack yarn install --frozen-lockfile` | Passed (no lockfile
changes) |
| `corepack yarn run compile-tests` (`tsc -p . --outDir out`) | Passed |
| `corepack yarn run compile-e2e` (`tsc -p tsconfig.e2e.json`) | Passed
|
| `corepack yarn run compile` (webpack) | Passed |
| `corepack yarn run lint` (`eslint src`) | Passed, no warnings |
| `corepack yarn run unit-test` (full suite) | 4151 passing, 9 pending,
2 failing. The 2 failures are `E2E download cache` tests (`fails before
publishing when a concurrent unusable generation fills the recovery
bound` and `observes a symlinked cache entry group without mutating it
before miss-path repair`): Windows filesystem `ctime`/symlink assertions
in untouched code that fail identically on an unmodified tree. |

Manual check against the real thing: I ran the repo's `Aspire.Dashboard`
over `https://localhost:18943` (Kestrel's default development
certificate), exported the certificate with the exact command the runner
uses, and called `waitForHttpText`. Without the pin it was rejected with
`self-signed certificate` (the CI condition); with
`ASPIRE_EXTENSION_E2E_DEV_CERT_PATH` set it returned the page.

Not run: the live VS Code E2E shards (`zeroToRunning`, `debugDashboard`,
`azureFunctions`) were not run locally because they need a repo-built
CLI, a packaged VSIX, ExTester-downloaded VS Code/ChromeDriver and NuGet
packages for the fixture AppHost; they run in `extension-e2e-tests.yml`.
Note that E2E shards with `advisoryIssue` can pass the job despite
completed test failures, so check the Mocha results of the HTTPS-probing
shards and not just the job conclusion.

### Security considerations

This change removes a disabled-certificate-validation pattern from test
code. The runner reads the dev-certs public certificate (no private key)
from the user's certificate store and writes it under the per-run temp
root, which is deleted at the end of the run; if no development
certificate exists on the machine, `dotnet dev-certs` creates one
without trusting it, which matches what the CLI already does on first
run. Reviewers should confirm the trust is limited to the exported
certificate (`ca` replaces the default roots for these requests only)
and that no E2E helper regains a verification bypass.

Fixes # (issue)
---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
(cherry picked from commit 7dc0df2)
@github-actions

This comment has been minimized.

@mitchdenny

Copy link
Copy Markdown
Member Author

Approved for inclusion in release/17.0. Do not merge yet.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 22043

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 22043"

@github-actions

This comment has been minimized.

@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-backport-17-0-45-pr21898 branch from 5f85a44 to bd3d1da Compare November 10, 2026 06:23
@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-backport-17-0-45-pr21898 branch from bd3d1da to 5f85a44 Compare November 10, 2026 07:58
@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

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.

2 participants