Skip to content
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