Get timestamp from Authenticode Signed files in .NET

前端 未结 7 1013
广开言路
广开言路 2020-11-30 04:53

We need to verify that binary files are signed properly with digital signature (Authenticode). This can be achieved with signtool.exe pretty easily. However, we need an auto

7条回答
  •  粉色の甜心
    2020-11-30 05:24

    Thank you guys,

    You help me a lot :)

    BTW: I found simpler way how to obtain the time stamp.

    here it is:

    foreach (var signerInfo in signedCms.SignerInfos)
    {
      foreach (var unsignedAttribute in signerInfo.UnsignedAttributes)
      {
        if (unsignedAttribute.Oid.Value == WinCrypt.szOID_RSA_counterSign)
        {
          foreach (var counterSignInfo in signerInfo.CounterSignerInfos)
          {
            foreach (var signedAttribute in counterSignInfo.SignedAttributes)
            {
              if (signedAttribute.Oid.Value == WinCrypt.szOID_RSA_signingTime)
              {
                Pkcs9SigningTime signingTime = (Pkcs9SigningTime)signedAttribute.Values[0];
                Console.Out.WriteLine("Signing Time UTC: " + signingTime.SigningTime);
              }
            }
          }
          return true;
        }
      }
    }
    

提交回复
热议问题