/// <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; } }