Skip to content

Add regression test for expired self-signed trusted chain (#48794) - #131398

Merged
bartonjs merged 2 commits into
dotnet:mainfrom
virzak:test/48794-expired-selfsigned-chain
Sep 3, 2026
Merged

bartonjs merged 2 commits into
dotnet:mainfrom
virzak:test/48794-expired-selfsigned-chain

Conversation

@virzak

@virzak virzak commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Regression test for #48794.

Background

The issue reported that on Linux, building a chain for an expired, trusted self-issued (self-signed) certificate with

ChainPolicy.VerificationFlags = X509VerificationFlags.IgnoreNotTimeValid;
ChainPolicy.RevocationMode = X509RevocationMode.Online;
ChainPolicy.RevocationFlag = X509RevocationFlag.ExcludeRoot;
ChainPolicy.VerificationTime = DateTime.Now;

returned Build() == false with NotTimeValid,RevocationStatusUnknown,UntrustedRoot, while Windows returned true. The report was filed against .NET 5 / OpenSSL 1.1.

Findings

The scenario no longer reproduces on current main. Verified end-to-end against a locally built runtime, including the faithful variant that installs the certificate into the user Root trust store (mirroring update-ca-certificates): the chain now builds successfully with NotTimeValid as the only (ignored) status, matching Windows and macOS.

Confirmed this holds across both supported OpenSSL lines — a native reproduction of the verify path returns X509_V_ERR_CERT_HAS_EXPIRED (not an untrusted-root code) for an expired self-signed trust anchor on both OpenSSL 1.1.1 and 3.0. The behavior was closed by intervening chain-handling changes since .NET 5 (notably #66968, "Fix revocation processing on expired chains").

Change

Adds DynamicChainTests.BuildChainForExpiredSelfSignedCertificate, a [Theory] over NoCheck and Online (ExcludeRoot) revocation, asserting that an expired trusted self-signed certificate builds successfully, does not report UntrustedRoot/PartialChain, and surfaces only the ignored NotTimeValid. This locks in the correct cross-platform behavior. Test-only; no product code changes.

@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Jul 26, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @bartonjs, @vcsjones, @dotnet/area-system-security
See info in area-owners.md if you want to be subscribed.

@virzak
virzak force-pushed the test/48794-expired-selfsigned-chain branch from 290e3ce to ce3e1ce Compare July 26, 2026 18:19

@bartonjs bartonjs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Two minor things, otherwise looks good. Thanks :)

An expired self-issued (self-signed) certificate that is trusted should
build successfully when NotTimeValid is ignored, with the certificate's
expiration being the only reported error, matching Windows and macOS.

The originally reported failure (Build returning false with
NotTimeValid,RevocationStatusUnknown,UntrustedRoot on Linux) no longer
reproduces on current main across OpenSSL 1.1.1 and 3.0; this test locks
in the correct cross-platform behavior for both NoCheck and Online
(ExcludeRoot) revocation modes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@virzak
virzak force-pushed the test/48794-expired-selfsigned-chain branch from ce3e1ce to 679be73 Compare July 26, 2026 19:46
@virzak

virzak commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Both addressed in the latest push: dropped the comment block and removed the unused revocationFlag parameter (it was always ExcludeRoot, the default), so the theory now varies only RevocationMode.

@bartonjs
bartonjs merged commit 25f20c2 into dotnet:main Sep 3, 2026
77 of 79 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Security community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants