MailBee.Security Namespace

MailBee.Security namespace contains additional types specific to TLS/SSL functionality, S/MIME support, certificates and certificate stores, DomainKeys/DKIM anti-spam technology.

The option to connect to SSL/TSL enabled mail server is available at no additional cost. The same applies to DomainKeys/DKIM - it's considered as a basic feature. You can sign e-mails with DomainKeys/DKIM signatures and verify DomainKeys/DKIM signatures of existing e-mails (this is a popular antispam check, many mail services nowdays accept only DomainKeys-signed e-mails).

With the help of advanced features (Security.Powerup license required), the developer can:

  • Work with certificates and their Windows registry and file stores.
  • Examine or validate server certificates and specify client certificates within TLS/SSL connections.
  • Encrypt, decrypt, verify, and sign e-mail messages.
  • Let the current thread programmatically impersonate another user (useful if the application needs to access resources, such as certificate stores, which belong to another user).

Some methods and functionality is Win32-specific and is not available or makes no sense in .NET Standard 2.0 edition (which is cross-platform) and in UWP editions:

  • Certificate stores support is limited. No way to create system-level stores. Also, finding certificates in the store is not efficient. Therefore it should be avoided.
  • Use methods like Smime.Decrypt2, Smime.Verify2 and Smime.DecryptAndVerify2 (with 2 suffix). They accept certificate collections rather than search certificate stores for the required certificates (which would be very slow in .NET Core and UWP environment).
  • No impersonation support (has no practical meaning in .NET Core and UWP anyway).
  • No NTLM/GSSAPI support via Win32 API (the managed code implementation is still available).

Classes
  ClassDescription
Public classCode exampleAlgorithm
Represents a cryptographic algorithm used for signing and encryption operations.
Public classCode exampleCertificate
Provides methods and properties for accessing a digital certificate.
Public classCode exampleCertificateCollection
Provides methods and properties for accessing collections of Certificate objects.
Public classCode exampleCertificateStore
Provides the methods and properties for accessing certificate stores.
Public classCode exampleClientServerCertificates
Provides methods and properties for accessing client and server certificates which are used in order to establish secure SSL connection with a mail server.
Public classCode exampleCryptoServiceProvider
Provides methods and properties for accessing or examining Cryptographic Service Providers (CSPs) registered in the system.
Public classCode exampleDomainKeys
Provides methods for signing e-mails with DomainKeys and DKIM signatures and verifying signatures of incoming e-mails.
Public classCode exampleImpersonation
Provides access to the impersonation functions.
Public classMailBeeCertificateException
An abstract parent for all exceptions that are thrown on errors which occur during accessing certificates.
Public classMailBeeCertificateParsingException
The exception which is thrown when it's not possible to parse the certificate data or when the certificate password is incorrect.
Public classMailBeeCertificateStoreException
An abstract parent for all exceptions that are thrown on errors which occur during accessing certificate stores.
Public classMailBeeCertificateStoreWin32Exception
The exception which is thrown when the underlying WinAPI function related to certificate store management returns an error.
Public classCode exampleMailBeeCertificateValidationException
The exception which is thrown during TLS/SSL handshake when automatic certificate validation is enabled and the server certificate does not pass the specified validation conditions.
Public classMailBeeCertificateWin32Exception
The exception which is thrown when the underlying WinAPI function related to certificate management returns an error.
Public classMailBeeCryptoProviderException
An abstract parent for all exceptions that are thrown on errors which occur during obtaining or examining Cryptographic Service Provider (CSP) system objects.
Public classMailBeeCryptoProviderWin32Exception
The exception which is thrown when the underlying CSP-related WinAPI function returns an error.
Public classMailBeeDomainKeysException
The exception that is thrown when DomainKeys operation (signing or verification) cannot be performed.
Public classMailBeeImpersonationException
An abstract parent for all exceptions that are thrown on errors which occur during starting or termniating the impersonation.
Public classMailBeeImpersonationWin32Exception
The exception which is thrown when the underlying WinAPI function related to impersonation returns an error.
Public classMailBeeSmimeException
An abstract parent for all exceptions that are thrown on errors which occur during performing S/MIME operations.
Public classMailBeeSmimeWin32Exception
The exception which is thrown when the underlying S/MIME WinAPI function responsible for decrypting, encrypting or signing data returns an error.
Public classMailBeeSslException
An abstract parent for all exceptions that are thrown on TLS/SSL negotiation, decryption and encryption errors.
Public classMailBeeSslNegotiationException
The exception that is thrown when the underlying SslStream throws an exception during SSL negotiation.
Public classMailBeeSslWin32Exception
The exception that is thrown when underlying Win32 Schannel implementation of TLS/SSL functions returns an error.
Public classPowerup
Explains which features of MailBee.Security namespace require Security license.
Public classCode exampleSmime
Provides properties and methods for encrypting, decrypting, signing and verifying e-mail messages.
Public classCode exampleSmimeResult
Provides access to the decrypted message, signature verification status and other values returned by the methods of Smime class.
Enumerations
  EnumerationDescription
Public enumerationAlgorithmCategory
Defines purposes of cryptographic algorithms.
Public enumerationCertFileType
Defines types of certificate files and data.
Public enumerationCertificateFields
Defines certificate fields available for search with FindCertificates(String, CertificateFields) method.
Public enumerationCertificateValidationFlags
Defines flags indicating errors of certificate validation.
Public enumerationCertStoreFileType
Defines types of certificate store files.
Public enumerationCertStoreType
Defines certificate store types.
Public enumerationDomainKeysTypes
Defines the supported types of DomainKeys technology (classic DK and DKIM).
Public enumerationDomainKeysVerifyResult
Defines the return values of Verify(MailMessage, Smtp) method.
Public enumerationMessageVerificationFlags
Defines criteria of verification of e-mail message signatures.
Public enumerationRegistryStoreLocation
Defines branches of the Windows registry where the system certificate stores can reside.
Public enumerationSecurityProtocol
Specifies the protocols to be used for performing TLS/SSL negotiation and data encryption.
Public enumerationSslStartupMode
Specifies in which way the mailer component should switch the connection into TLS/SSL mode.