SmimeDecrypt2 Method |
Namespace: MailBee.Security
Exception | Condition |
---|---|
MailBeeInvalidArgumentException | message is a null reference (Nothing in Visual Basic). |
MailBeeCertificateException | A 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. |
This method looks for the appropriate certificate for decryption in the Personal storage and in the specified certificates. The certificate in question must contain a private key.
To access the decrypted message, use DecryptedMessage property of the returned SmimeResult object. To get the certificate used for decryption, use DecryptionCertificate property of the same object.
To check if the original message was encrypted, examine IsEncrypted property value of the original MailMessage object.
To decrypt and verify a message within a single method call, use DecryptAndVerify(MailMessage, MessageVerificationFlags) method or its overloads.
This method is a version of Decrypt(MailMessage, 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.
Note |
---|
This method is not available in .NET Сore 1.0/1.1. On that platform, use Decrypt(MailMessage, CertificateStore) instead. |