You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public static List<X509Certificate2> GetSigningCertificates(this PeFile pefile)
{
var data = DecodeCertificateData(pefile.WinCertificate?.BCertificate.ToArray());
var result = new List<X509Certificate2>();
result.Add(pefile.Authenticode.SigningCertificate);
foreach (var cert in data)
{
result.AddRange(GetNestedAuthenticodeDetails(cert));
}
return result;
}
public static IEnumerable<SignerInfo> DecodeCertificateData(byte[] rawData)
{
var orgCms = new SignedCms();
orgCms.Decode(rawData);
return orgCms.SignerInfos.Cast<SignerInfo>();
}
public static List<X509Certificate2> GetNestedAuthenticodeDetails(SignerInfo cert)
{
var result = new List<X509Certificate2>();
List<CryptographicAttributeObject> data = new List<CryptographicAttributeObject>();
foreach (var item in cert.UnsignedAttributes)
{
if (item.Oid.Value == "1.3.6.1.4.1.311.2.4.1")
{
data.Add(item);
}
}
foreach (var item in data)
{
var CertificateList = DecodeCertificateData(item.Values[0].RawData);
foreach (var item1 in CertificateList)
{
result.Add(item1.Certificate);
}
}
return result;
}
What to do if the file has multiple digital signatures?
The text was updated successfully, but these errors were encountered: