AsymmetricAlgorithm.ImportFromEncryptedPem Method

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Overloads

ImportFromEncryptedPem(ReadOnlySpan<Char>, ReadOnlySpan<Char>)

When overridden in a derived class, imports an encrypted RFC 7468 PEM-encoded key, replacing the keys for this object.

ImportFromEncryptedPem(ReadOnlySpan<Char>, ReadOnlySpan<Byte>)

When overridden in a derived class, imports an encrypted RFC 7468 PEM-encoded key, replacing the keys for this object.

ImportFromEncryptedPem(ReadOnlySpan<Char>, ReadOnlySpan<Char>)

Source:
AsymmetricAlgorithm.cs
Source:
AsymmetricAlgorithm.cs
Source:
AsymmetricAlgorithm.cs

When overridden in a derived class, imports an encrypted RFC 7468 PEM-encoded key, replacing the keys for this object.

C#
public virtual void ImportFromEncryptedPem(ReadOnlySpan<char> input, ReadOnlySpan<char> password);

Parameters

input
ReadOnlySpan<Char>

The PEM text of the encrypted key to import.

password
ReadOnlySpan<Char>

The password to use for decrypting the key material.

Exceptions

A derived type has not overridden this member.

input does not contain a PEM-encoded key with a recognized label.

-or-

input contains multiple PEM-encoded keys with a recognized label.

The password is incorrect.

-or-

The base-64 decoded contents of the PEM text from input do not represent an ASN.1-BER-encoded PKCS#8 EncryptedPrivateKeyInfo structure.

-or-

The base-64 decoded contents of the PEM text from input indicate the key is for an algorithm other than the algorithm represented by this instance.

-or-

The base-64 decoded contents of the PEM text from input represent the key in a format that is not supported.

-or-

The algorithm-specific key import failed.

Remarks

Because each algorithm may have algorithm-specific PEM labels, the default behavior will throw NotImplementedException.

Applies to

.NET 10 and other versions
Product Versions
.NET 5, 6, 7, 8, 9, 10

ImportFromEncryptedPem(ReadOnlySpan<Char>, ReadOnlySpan<Byte>)

Source:
AsymmetricAlgorithm.cs
Source:
AsymmetricAlgorithm.cs
Source:
AsymmetricAlgorithm.cs

When overridden in a derived class, imports an encrypted RFC 7468 PEM-encoded key, replacing the keys for this object.

C#
public virtual void ImportFromEncryptedPem(ReadOnlySpan<char> input, ReadOnlySpan<byte> passwordBytes);

Parameters

input
ReadOnlySpan<Char>

The PEM text of the encrypted key to import.

passwordBytes
ReadOnlySpan<Byte>

The bytes to use as a password when decrypting the key material.

Exceptions

A derived type has not overridden this member.

input does not contain a PEM-encoded key with a recognized label.

-or-

input contains multiple PEM-encoded keys with a recognized label.

The password is incorrect.

-or-

The base-64 decoded contents of the PEM text from input do not represent an ASN.1-BER-encoded PKCS#8 EncryptedPrivateKeyInfo structure.

-or-

The base-64 decoded contents of the PEM text from input indicate the key is for an algorithm other than the algorithm represented by this instance.

-or-

The base-64 decoded contents of the PEM text from input represent the key in a format that is not supported.

-or-

The algorithm-specific key import failed.

Remarks

Because each algorithm may have algorithm-specific PEM labels, the default behavior will throw NotImplementedException.

Applies to

.NET 10 and other versions
Product Versions
.NET 5, 6, 7, 8, 9, 10