Ejemplo n.º 1
0
 /// <summary>
 /// Verify file signature for current signed certificate.
 /// </summary>
 /// <param name="filename">An filename to verify.</param>
 /// <returns>true if the file signature is valid; otherwise, false.</returns>
 /// <exception cref="ArgumentNullException">The filename is null.</exception>
 /// <remarks>
 /// Warning:
 ///     This method do not check certificate matched expected.
 ///     Before use it always call <see cref="VerifyFileCertificate(string)"/>
 ///     or use method which verify both <see cref="VerifyFile(string)"/>
 /// </remarks>
 public bool VerifyFileSignature(string filename)
 {
     if (filename == null)
     {
         throw new ArgumentNullException(nameof(filename));
     }
     return(WinTrust.VerifyEmbeddedSignature(filename));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Verify file signature for current signed certificate.
        /// </summary>
        /// <param name="filename">An filename to verify.</param>
        /// <returns>true if the file signature is valid; otherwise, false.</returns>
        /// <exception cref="ArgumentNullException">The filename is null.</exception>
        /// <remarks>
        /// Warning:
        ///     This method do not check certificate matched expected.
        ///     Before use it always call <see cref="VerifyFileCertificate(string)"/>
        ///     or use method which verify both <see cref="VerifyFile(string)"/>
        /// </remarks>
        public bool VerifyFileSignature(string filename)
        {
            if (filename == null)
            {
                throw new ArgumentNullException(nameof(filename));
            }
            _logger.Info("Verify file signature");
            var result = WinTrust.VerifyEmbeddedSignature(filename);

            _logger.Info($"Verify file signature result: {result}");
            return(result == WinVerifyTrustResult.Success ||
                   result == WinVerifyTrustResult.UntrustedRoot ||
                   result == WinVerifyTrustResult.CertChaining);
        }