Skip to content

NuGetPackageDownloader: Stop verifying the package signature on Mac and queue off of the environment on Linux #47463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ internal class NuGetPackageDownloader : INuGetPackageDownloader
private readonly ConcurrentDictionary<PackageSource, SourceRepository> _sourceRepositories;
private readonly bool _shouldUsePackageSourceMapping;

/// <summary>
/// If true, the package downloader will verify the signatures of the packages it downloads.
/// Temporarily disabled for macOS and Linux.
/// </summary>
private readonly bool _verifySignatures;
private readonly VerbosityOptions _verbosityOptions;
private readonly string _currentWorkingDirectory;
Expand Down Expand Up @@ -66,7 +70,9 @@ public NuGetPackageDownloader(
_restoreActionConfig = restoreActionConfig ?? new RestoreActionConfig();
_retryTimer = timer;
_sourceRepositories = new();
_verifySignatures = verifySignatures;
// If windows or env variable is set, verify signatures
_verifySignatures = verifySignatures && (OperatingSystem.IsWindows() ? true
: bool.TryParse(Environment.GetEnvironmentVariable(NuGetSignatureVerificationEnabler.DotNetNuGetSignatureVerification), out var shouldVerifySignature) ? shouldVerifySignature : OperatingSystem.IsLinux());

_cacheSettings = new SourceCacheContext
{
Expand Down Expand Up @@ -127,8 +133,17 @@ public async Task<string> DownloadPackageAsync(PackageId packageId,
packageVersion.ToNormalizedString()));
}

await VerifySigning(nupkgPath, repository);

// Delete file if verification fails
try
{
await VerifySigning(nupkgPath, repository);
}
catch (NuGetPackageInstallerException)
{
File.Delete(nupkgPath);
throw;
}

return nupkgPath;
}

Expand Down
Loading