SmimeDecryptAndVerify2 Method
Decrypts an e-mail message if it's encrypted and verifies its signature if it's signed.

Namespace: MailBee.Security
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax
public SmimeResult DecryptAndVerify2(
	MailMessage message,
	MessageVerificationFlags flags,
	X509Certificate2Collection extraCertsForDecrypt,
	X509Certificate2Collection extraCertsForVerify
)

Parameters

message
Type: MailBee.MimeMailMessage
The original message to be decrypted and verified.
flags
Type: MailBee.SecurityMessageVerificationFlags
A set of flags which specify the verification criteria.
extraCertsForDecrypt
Type: System.Security.Cryptography.X509CertificatesX509Certificate2Collection
The additional certificates to be searched for the appropriate certificate for decrypting the message, or a null reference (Nothing in Visual Basic) if only Personal system storage should be used.
extraCertsForVerify
Type: System.Security.Cryptography.X509CertificatesX509Certificate2Collection
The additional certificates of the certification authorities, or a null reference (Nothing in Visual Basic) if only the system default certification authorities should be used for validating the certificate of the message signature.

Return Value

Type: SmimeResult
A reference to SmimeResult object containing either the decrypted message or the original message if it was not encrypted; a null reference (Nothing in Visual Basic) if the decryption process failed.
Exceptions
ExceptionCondition
MailBeeInvalidArgumentExceptionmessage is a null reference (Nothing in Visual Basic).
MailBeeCertificateExceptionA cryptographic error occurred and ThrowExceptions is true. Typically, if the error message is "Keyset does not exist", indicates that there is no private key in the certicate required for decryption.
Remarks

The returned SmimeResult object provides access to the return values of this method, including DecryptedMessage, DecryptionCertificate, VerificationResult, and SignatureCertificate.

Thus, to access the decrypted message, use DecryptedMessage property; to get the certificate used for decryption, use DecryptionCertificate property.

To check the result of the message signature verification, examine VerificationResult property value. To access the signature certificate, use SignatureCertificate property.

See Decrypt(MailMessage) and Verify(MailMessage, MessageVerificationFlags, CertificateStore) topics for more details on decryption and verification process.

This method is a version of DecryptAndVerify(MailMessage, MessageVerificationFlags, CertificateStore, CertificateStore) which accepts X509Certificate2Collection rather than CertificateStore. Starting from .NET Standard 2.0, you must use this method as CertificateStore functionality has been reduced to avoid dependency on Win32 API.

See Also