Click or drag to resize
MimeKit

SecureMimeContextImportAsync(String, String, CancellationToken) Method

Asynchronously imports certificates and keys from a pkcs12 file.

Namespace: MimeKit.Cryptography
Assembly: MimeKit (in MimeKit.dll) Version: 4.7.1
Syntax
C#
public virtual Task ImportAsync(
	string fileName,
	string password,
	CancellationToken cancellationToken = default
)

Parameters

fileName  String
The raw certificate and key data in pkcs12 format.
password  String
The password to unlock the stream.
cancellationToken  CancellationToken  (Optional)
The cancellation token.

Return Value

Task
An asynchronous task context.

Implements

ISecureMimeContextImportAsync(String, String, CancellationToken)
Exceptions
ExceptionCondition
ArgumentNullException

fileName is null.

-or-

password is null.

ArgumentException

fileName is a zero-length string, contains only white space, or contains one or more invalid characters.

-or-

fileName does not contain a private key.

-or-

fileName does not contain a certificate that could be used for signing.

DirectoryNotFoundExceptionfileName is an invalid file path.
FileNotFoundException The specified file path could not be found.
UnauthorizedAccessException The user does not have access to read the specified file.
IOException An I/O error occurred.
NotSupportedException Importing keys is not supported by this cryptography context.
OperationCanceledException The operation was cancelled via the cancellation token.
Remarks
Asynchronously imports certificates and keys from a pkcs12 file.
See Also