/// <summary>
        /// Verifies the digital signature.
        /// </summary>
        /// <remarks>
        /// Verifies the digital signature.
        /// </remarks>
        /// <returns><c>true</c> if the signature is valid; otherwise <c>false</c>.</returns>
        /// <exception cref="DigitalSignatureVerifyException">
        /// An error verifying the signature has occurred.
        /// </exception>
        public bool Verify()
        {
            if (valid.HasValue)
            {
                return(valid.Value);
            }

            if (vex != null)
            {
                throw vex;
            }

            if (SignerCertificate == null)
            {
                var message = string.Format("Failed to verify digital signature: missing certificate.");
                vex = new DigitalSignatureVerifyException(message);
                throw vex;
            }

            try {
                var certificate = ((SecureMimeDigitalCertificate)SignerCertificate).Certificate;
                valid = SignerInfo.Verify(certificate);
                return(valid.Value);
            } catch (Exception ex) {
                var message = string.Format("Failed to verify digital signature: {0}", ex.Message);
                vex = new DigitalSignatureVerifyException(message, ex);
                throw vex;
            }
        }
        /// <summary>
        /// Verifies the digital signature.
        /// </summary>
        /// <remarks>
        /// Verifies the digital signature.
        /// </remarks>
        /// <returns><c>true</c> if the signature is valid; otherwise <c>false</c>.</returns>
        /// <exception cref="DigitalSignatureVerifyException">
        /// An error verifying the signature has occurred.
        /// </exception>
        public bool Verify()
        {
            if (valid.HasValue)
            {
                return(valid.Value);
            }

            if (vex != null)
            {
                throw vex;
            }

            if (SignerCertificate == null)
            {
                var message = string.Format("Failed to verify digital signature: no public key found for {0}", Signature.KeyId);
                vex = new DigitalSignatureVerifyException(message);
                throw vex;
            }

            try {
                if (OnePassSignature != null)
                {
                    valid = OnePassSignature.Verify(Signature);
                }
                else
                {
                    valid = Signature.Verify();
                }
                return(valid.Value);
            } catch (Exception ex) {
                var message = string.Format("Failed to verify digital signature: {0}", ex.Message);
                vex = new DigitalSignatureVerifyException(message, ex);
                throw vex;
            }
        }
Exemple #3
0
        /// <summary>
        /// Verifies the digital signature.
        /// </summary>
        /// <remarks>
        /// Verifies the digital signature.
        /// </remarks>
        /// <returns><c>true</c> if the signature is valid; otherwise <c>false</c>.</returns>
        /// <exception cref="DigitalSignatureVerifyException">
        /// An error verifying the signature has occurred.
        /// </exception>
        public bool Verify()
        {
            if (vex != null)
            {
                throw vex;
            }

            try {
                SignerInfo.CheckSignature(false);
                return(true);
            } catch (Exception ex) {
                var message = string.Format("Failed to verify digital signature: {0}", ex.Message);
                vex = new DigitalSignatureVerifyException(message, ex);
                throw vex;
            }
        }
		/// <summary>
		/// Verifies the digital signature.
		/// </summary>
		/// <remarks>
		/// Verifies the digital signature.
		/// </remarks>
		/// <returns><c>true</c> if the signature is valid; otherwise <c>false</c>.</returns>
		/// <exception cref="DigitalSignatureVerifyException">
		/// An error verifying the signature has occurred.
		/// </exception>
		public bool Verify ()
		{
			if (valid.HasValue)
				return valid.Value;

			if (vex != null)
				throw vex;

			if (SignerCertificate == null) {
				var message = string.Format ("Failed to verify digital signature: no public key found for {0}", Signature.KeyId);
				vex = new DigitalSignatureVerifyException (message);
				throw vex;
			}

			try {
				if (OnePassSignature != null)
					valid = OnePassSignature.Verify (Signature);
				else
					valid = Signature.Verify ();
				return valid.Value;
			} catch (Exception ex) {
				var message = string.Format ("Failed to verify digital signature: {0}", ex.Message);
				vex = new DigitalSignatureVerifyException (message, ex);
				throw vex;
			}
		}
		/// <summary>
		/// Verifies the digital signature.
		/// </summary>
		/// <remarks>
		/// Verifies the digital signature.
		/// </remarks>
		/// <returns><c>true</c> if the signature is valid; otherwise <c>false</c>.</returns>
		/// <exception cref="DigitalSignatureVerifyException">
		/// An error verifying the signature has occurred.
		/// </exception>
		public bool Verify ()
		{
			if (valid.HasValue)
				return valid.Value;

			if (vex != null)
				throw vex;

			if (SignerCertificate == null) {
				var message = string.Format ("Failed to verify digital signature: missing certificate.");
				vex = new DigitalSignatureVerifyException (message);
				throw vex;
			}

			try {
				var certificate = ((SecureMimeDigitalCertificate) SignerCertificate).Certificate;
				valid = SignerInfo.Verify (certificate);
				return valid.Value;
			} catch (Exception ex) {
				var message = string.Format ("Failed to verify digital signature: {0}", ex.Message);
				vex = new DigitalSignatureVerifyException (message, ex);
				throw vex;
			}
		}