Open
Conversation
Now that we have `TARGET_` defines, further simplify the code to make it clear that we aren't checking for signatures outside of Windows for Workloads.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to simplify workload signature-check logic now that TARGET_ defines exist, making it explicit that signature checking is Windows-only.
Changes:
- Simplifies
SignCheck_Windowsby removing runtime OS checks and#if TARGET_WINDOWSblocks, assuming Windows-only compilation. - Deletes the Unix
SignCheckstub implementation. - Removes the now-unnecessary csproj rule that excluded the Unix
SignCheckfile on Windows builds.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Cli/dotnet/dotnet.csproj | Removes the conditional compile exclusion for the Unix SignCheck file. |
| src/Cli/dotnet/Commands/Workload/SignCheck_Windows.cs | Makes SignCheck strictly Windows-assumptive (no OS branching / conditional compilation). |
| src/Cli/dotnet/Commands/Workload/SignCheck_Unix.cs | Removes the non-Windows SignCheck stub. |
Refactor the workload signing verification pipeline for clarity and correctness. The two independent verification systems (NuGet package signatures and MSI Authenticode) were easy to confuse due to ambiguous naming, inconsistent defaults, and duplicated NuGetPackageDownloader construction across call sites. Bug fix: - WorkloadInfoHelper passed `!SignCheck.IsDotNetSigned()` as the default for MSI verification — inverted logic that verified when the host was unsigned and skipped when signed. Fixed to use `WorkloadUtilities.ShouldVerifySignatures()`. (No real exposure as this is only an informational command, there is no execution / installation.) Behavioral change: - WorkloadManifestUpdater.GetInstance() previously called `SignCheck.IsDotNetSigned()` directly for NuGet verification, bypassing the registry policy check. Now calls parameterless `ShouldVerifySignatures()`, which additionally respects the VerifySignatures registry policy. MSI verification remains intentionally disabled (only downloads advertising manifests, not MSIs). Refactoring: - Add `WorkloadUtilities.ShouldVerifySignatures()` parameterless overload for non-interactive code paths that don't have a --skip-sign-check flag. - Add `NuGetPackageDownloader.CreateForWorkloads()` factory method to centralize the common construction pattern (FirstPartyVerifier, source mapping enabled, null logger). Replaces 6 inline constructor calls. - Rename `VerifyPackage()` to `ValidateMsiDatabase()` in NetSdkMsiInstallerClient to distinguish MSI database structure validation from cryptographic signature verification. - Rename `verifySignatures` parameter to `verifyMsiSignature` in InstallerBase, WorkloadInstallerFactory, MsiInstallerBase, NetSdkMsiInstallerClient, and WorkloadInfoHelper to clarify that the parameter controls MSI Authenticode verification only. - Log a diagnostic message when NuGetPackageDownloader's platform gate downgrades a verification request (e.g., on macOS without the env var). - Delete SignCheck_Unix.cs stub — unnecessary since ShouldVerifySignatures() returns false at compile time on non-Windows before any SignCheck method is called. Documentation: - Add SIGNING-VERIFICATION.md in the Workload directory covering the policy decision flow, platform support rationale, MSI Authenticode layer, and entry point map. - Add NUGET-SIGNATURE-VERIFICATION.md in the NuGetPackageDownloader directory covering the platform gate, TRP certificate bundles, verification modes (strict first-party vs. relaxed), and the NuGetSignatureVerificationEnabler distinction. - Add XML documentation throughout SignCheck_Windows, WorkloadUtilities, NuGetPackageDownloader, FirstPartyNuGetPackageSigningVerifier, and MsiPackageCache. Tests: - Add WorkloadUtilitiesTests (3 tests) for ShouldVerifySignatures overloads. - Add NuGetPackageDownloaderFactoryTests (4 tests) for CreateForWorkloads and the platform downgrade logging behavior.
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Clarify workload signing verification and fix WorkloadInfoHelper bug
Refactor the workload signing verification pipeline for clarity and
correctness. The two independent verification systems (NuGet package
signatures and MSI Authenticode) were easy to confuse due to ambiguous
naming, inconsistent defaults, and duplicated NuGetPackageDownloader
construction across call sites.
Bug fix:
!SignCheck.IsDotNetSigned()as the defaultfor MSI verification — inverted logic that verified when the host was
unsigned and skipped when signed. Fixed to use
WorkloadUtilities.ShouldVerifySignatures(). (No real exposure as this is only an informational command, there is no execution / installation.)Behavioral change:
SignCheck.IsDotNetSigned()directly for NuGet verification, bypassingthe registry policy check. Now calls parameterless
ShouldVerifySignatures(), which additionally respects theVerifySignatures registry policy. MSI verification remains intentionally
disabled (only downloads advertising manifests, not MSIs).
Refactoring:
WorkloadUtilities.ShouldVerifySignatures()parameterless overloadfor non-interactive code paths that don't have a --skip-sign-check flag.
NuGetPackageDownloader.CreateForWorkloads()factory method tocentralize the common construction pattern (FirstPartyVerifier, source
mapping enabled, null logger). Replaces 6 inline constructor calls.
VerifyPackage()toValidateMsiDatabase()inNetSdkMsiInstallerClient to distinguish MSI database structure
validation from cryptographic signature verification.
verifySignaturesparameter toverifyMsiSignatureinInstallerBase, WorkloadInstallerFactory, MsiInstallerBase,
NetSdkMsiInstallerClient, and WorkloadInfoHelper to clarify that the
parameter controls MSI Authenticode verification only.
downgrades a verification request (e.g., on macOS without the env var).
ShouldVerifySignatures() returns false at compile time on non-Windows
before any SignCheck method is called.
Documentation:
policy decision flow, platform support rationale, MSI Authenticode
layer, and entry point map.
directory covering the platform gate, TRP certificate bundles,
verification modes (strict first-party vs. relaxed), and the
NuGetSignatureVerificationEnabler distinction.
NuGetPackageDownloader, FirstPartyNuGetPackageSigningVerifier, and
MsiPackageCache.
Tests:
overloads.
and the platform downgrade logging behavior.