TemporarySecureMimeContextImport(X509Certificate, Boolean, CancellationToken) Method

Import a certificate and explicitly set its trust.

Definition

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

Parameters

certificate  X509Certificate
The certificate.
trusted  Boolean
Whether the certificate is a trusted anchor.
cancellationToken  CancellationToken  (Optional)
The cancellation token.

Remarks

Only certificates explicitly imported with trusted set to are used as trust anchors. Ordinary imports, including certificates received in signed messages or imported from PKCS#12, do not grant trust or change existing trust.

Passing removes any previously granted trust.

Exceptions

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

See Also