<PackageReference Include="Azure.Core" Version="1.53.0" />

Azure.Core.LightweightPkcs8Decoder

This is a very targeted PKCS#8 decoder for use when reading a PKCS# encoded RSA private key from an DER encoded ASN.1 blob. In an ideal world, we would be able to call AsymmetricAlgorithm.ImportPkcs8PrivateKey off an RSA object to import the private key from a byte array, which we got from the PEM file. There are a few issues with this however: 1. ImportPkcs8PrivateKey does not exist in the Desktop .NET Framework as of today. 2. ImportPkcs8PrivateKey was added to .NET Core in 3.0, and we'd love to be able to support this on older versions of .NET Core. This code is able to decode RSA keys (without any attributes) from well formed PKCS#8 blobs.
public static string DecodePrivateKeyOid(byte[] pkcs8Bytes)

public static RSA DecodeRSAPkcs8(byte[] pkcs8Bytes)