Skip to content

[release/13.0] Use DateTimeOffset.Now for checking certificate validity#12715

Merged
joperezr merged 1 commit intodotnet:release/13.0from
danegsta:danegsta/backport12680
Nov 6, 2025
Merged

[release/13.0] Use DateTimeOffset.Now for checking certificate validity#12715
joperezr merged 1 commit intodotnet:release/13.0from
danegsta:danegsta/backport12680

Conversation

@danegsta
Copy link
Member

@danegsta danegsta commented Nov 5, 2025

Backport of #12680 to release/13.0

Customer Impact

This fixes a time zone bug checking for dev cert validity and makes Python apps default to only trusting the dev cert for OTEL (instead of trusting the dev cert for all http clients) to avoid a potential issue with the Windows cert store being more permissive with certificates than OpenSSL is.

Testing

Manual testing with users in different time zones generating dev certs as well as a user with a problematic certificate validating that the python certificate set change unblocked them.

Risk

Low. We're matching the behavior of ASP.NET for developer certificate validation and limiting the default certificate set for Python to the dev cert for OTEL only.

Regression?

No

* Use DateTimeOffset.Now for checking certificate validity

* Avoid loading all system certificates until we can validate them via DCP

* Ensure comment covers usage of DateTimeOffset.Now as well
Copilot AI review requested due to automatic review settings November 5, 2025 21:43
@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 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 -- 12715

Or

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

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 makes two changes to improve certificate handling and Python resource configuration:

  • Updates DeveloperCertificateService to use DateTimeOffset.Now instead of DateTime.UtcNow for consistency with ASP.NET Core's certificate selection logic
  • Modifies Python resource configuration to remove the default CertificateTrustScope.System setting and downgrades a warning to informational logging

Reviewed Changes

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

File Description
src/Aspire.Hosting/DeveloperCertificateService.cs Changes time comparison from DateTime.UtcNow to DateTimeOffset.Now and repositions related comments to align with ASP.NET Core's certificate selection behavior
src/Aspire.Hosting.Python/PythonAppResourceBuilderExtensions.cs Removes automatic CertificateTrustScope.System configuration and changes log level from warning to informational for unsupported Append mode

// Python defaults to using System scope to allow combining custom CAs with system CAs as there's no clean
// way to simply append additional certificates to default Python trust stores such as certifi.
// Configure required environment variables for custom certificate trust when running as an executable.
// TODO: Make CertificateTrustScope.System the default once we're able to validate that certificates are valid for OpenSSL. Otherwise we potentially add invalid certificates to the bundle which causes OpenSSL to error.
Copy link
Member

Choose a reason for hiding this comment

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

Do we have an issue tracking this?

Copy link
Member Author

Choose a reason for hiding this comment

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

@joperezr
Copy link
Member

joperezr commented Nov 5, 2025

Customer reported, important for our polyglot story, fixes a correctness issue. Approved.

@joperezr joperezr added the Servicing-approved Approved for servicing release label Nov 5, 2025
@danegsta danegsta added this to the 13.0 milestone Nov 6, 2025
@joperezr joperezr merged commit 1a2f10e into dotnet:release/13.0 Nov 6, 2025
588 of 592 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Dec 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants