DefaultSecureMimeContextImportAsync(X509Certificate, Boolean, CancellationToken) Method

Asynchronously import a certificate.

Definition

Namespace: MimeKit.Cryptography
Assembly: MimeKit.Cryptography (in MimeKit.Cryptography.dll) Version: 5.0.0
C#
public Task ImportAsync(
	X509Certificate certificate,
	bool trusted,
	CancellationToken cancellationToken = default
)

Parameters

certificate  X509Certificate
The certificate.
trusted  Boolean
if the certificate is trusted; otherwise, .
cancellationToken  CancellationToken  (Optional)
The cancellation token.

Return Value

Task
An asynchronous task context.

Remarks

Asynchronously imports the certificate.

If the certificate already exists in the database and trusted is , then the IsTrusted state is updated otherwise the certificate is added to the database with the specified trust.

  Note

The certificate database is accessed synchronously because IX509CertificateDatabase does not provide asynchronous APIs, so this method will block the calling thread until the import has completed.

Exceptions

ArgumentNullException certificate is .
OperationCanceledException The operation was canceled via the cancellation token.

See Also