Skip to content

Fix obsolete X509Certificate2 Errors #14919

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
merged 4 commits into from
Jul 10, 2024
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
11 changes: 11 additions & 0 deletions src/Microsoft.DotNet.SignTool/src/VerifySignatures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Threading;

Expand Down Expand Up @@ -101,8 +102,18 @@ internal static bool IsDigitallySigned(string fullPath)
X509Certificate2 certificate;
try
{
// We later suppress SYSLIB0057 because X509CertificateLoader does not handle authenticode inputs
// so we should verify that the certificate is authenticode before using X509Certificate2.CreateFromSignedFile
var certContentType = X509Certificate2.GetCertContentType(fullPath);
if (certContentType != X509ContentType.Authenticode)
{
return false;
}

#pragma warning disable SYSLIB0057 // Suppress obsoletion warning for CreateFromSignedFile
X509Certificate signer = X509Certificate2.CreateFromSignedFile(fullPath);
certificate = new X509Certificate2(signer);
#pragma warning restore SYSLIB0057
}
catch (Exception)
{
Expand Down
Loading