PemReader.GetPrivateKey

GetPrivateKey(Stream)

Reads an RSA private key from a PEM-encoded stream.

public static RSACryptoServiceProvider GetPrivateKey(Stream pem)
ParameterTypeDescription
pemStreamStream with the PEM-encoded private key, in PKCS#1 or PKCS#8 format.

Return Value

An RSA provider initialized with the private key.

Exceptions

exceptioncondition
FormatExceptionThe stream does not contain a supported PEM private key.

See Also


GetPrivateKey(string)

Reads an RSA private key from a PEM file.

public static RSACryptoServiceProvider GetPrivateKey(string path)
ParameterTypeDescription
pathStringPath to the PEM file with the private key.

Return Value

An RSA provider initialized with the private key.

Exceptions

exceptioncondition
FormatExceptionThe file does not contain a supported PEM private key.

See Also