Click or drag to resize
MimeKit

SecureMimeContextImport(String, String, CancellationToken) Method

Imports certificates and keys from a pkcs12 file.

Namespace: MimeKit.Cryptography
Assembly: MimeKit (in MimeKit.dll) Version: 4.7.1
Syntax
C#
public virtual void Import(
	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.

Implements

ISecureMimeContextImport(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
Imports certificates and keys from a pkcs12 file.
See Also