Beispiel #1
0
        // constructor for silent WinTrustDataChoice.File check
        public WinTrustData(WinTrustFileInfo fileInfo)
        {
            WinTrustFileInfo wtfiData = fileInfo;

            FileInfoPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(WinTrustFileInfo)));
            Marshal.StructureToPtr(wtfiData, FileInfoPtr, false);

            using (WinTrustSignatureSettings signatureSettings = new WinTrustSignatureSettings())
            {
                SignatureSettings = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(WinTrustSignatureSettings)));
                Marshal.StructureToPtr(signatureSettings, SignatureSettings, false);
            }
        }
Beispiel #2
0
 public static bool VerifyEmbeddedSignature(string fileName)
 {
     using (WinTrustFileInfo wtfi = new WinTrustFileInfo(fileName))
     {
         using (WinTrustData wtd = new WinTrustData(wtfi))
         {
             Guid guidAction             = new Guid(WINTRUST_ACTION_GENERIC_VERIFY_V2);
             WinVerifyTrustResult result = WinVerifyTrust(INVALID_HANDLE_VALUE, guidAction, wtd);
             return(result == WinVerifyTrustResult.Success ||
                    result == WinVerifyTrustResult.UntrustedRoot ||
                    result == WinVerifyTrustResult.CertChaining);
         }
     }
 }