Click or drag to resize
MimeKit

SecureMimeContextImport Method (String, String, CancellationToken)

Imports certificates and keys from a pkcs12 file.

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

Parameters

fileName
Type: SystemString
The raw certificate and key data in pkcs12 format.
password
Type: SystemString
The password to unlock the stream.
cancellationToken (Optional)
Type: System.ThreadingCancellationToken
The cancellation token.
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
Imports certificates and keys from a pkcs12 file.
See Also