Skip to content

Exclude localhost certificates without a subject key identifier extension#12736

Merged
danegsta merged 3 commits intodotnet:mainfrom
danegsta:danegsta/filterOutMissingSKI
Nov 6, 2025
Merged

Exclude localhost certificates without a subject key identifier extension#12736
danegsta merged 3 commits intodotnet:mainfrom
danegsta:danegsta/filterOutMissingSKI

Conversation

@danegsta
Copy link
Member

@danegsta danegsta commented Nov 6, 2025

Description

OpenSSL considers the subject name and the subject/authority key identifier extensions when considering what trusted certificates to validate a TLS connection against. The ASP.NET dev cert doesn't include a subject key identifier extension, but neither do the legacy IIS certificates. This can lead to conflicts when adding multiple certificates into an OpenSSL trust bundle.

This PR filters out localhost certificates without a subject key identifier from the store when adding system trust to a child resource. This ensures the ASP.NET developer certificate works, but does have the trade-off of prevent resources from trusting local IIS development endpoints.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2025

🚀 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/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12736

Or

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables Python apps to trust system root certificates in addition to custom certificates by setting CertificateTrustScope.System as the default, and filters out legacy localhost certificates to prevent OpenSSL conflicts.

Key Changes:

  • Python apps now default to CertificateTrustScope.System instead of Append mode
  • Added filtering logic to exclude legacy localhost certificates without Subject Key Identifier when loading system root certificates
  • Minor whitespace cleanup in XML documentation

Reviewed Changes

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

File Description
src/Aspire.Hosting/Utils/X509Certificate2Extensions.cs Added HasSubjectKeyIdentifier() method and filtering logic in AddRootCertificates() to exclude legacy localhost certificates that could conflict with ASP.NET Core dev certs in OpenSSL
src/Aspire.Hosting.Python/PythonAppResourceBuilderExtensions.cs Changed default certificate trust scope from Append to System for Python apps, removed TODO comment, and fixed trailing whitespace in XML doc

danegsta and others added 2 commits November 5, 2025 20:04
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@danegsta danegsta merged commit ba4b4ec into dotnet:main Nov 6, 2025
582 of 585 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 13.1 milestone Nov 6, 2025
@danegsta
Copy link
Member Author

danegsta commented Nov 6, 2025

/backport to release/13.0

@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2025

Started backporting to release/13.0: https://github.com/dotnet/aspire/actions/runs/19126133137

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants