<PackageReference Include="Microsoft.Bcl.Cryptography" Version="11.0.0-preview.7.26381.103" />

System.Security.Cryptography.X509Certificates.X509CertificateLoader

public static class X509CertificateLoader
Provides methods for loading an X.509 certificate or a PKCS#12 PFX containing certificates.
public static X509Certificate2 LoadCertificate(ReadOnlySpan<byte> data)

Loads a single X.509 certificate from data, in either the PEM or DER encoding.

public static X509Certificate2 LoadCertificate(byte[] data)

Loads a single X.509 certificate from data, in either the PEM or DER encoding.

public static X509Certificate2 LoadCertificateFromFile(string path)

Loads a single X.509 certificate (in either the PEM or DER encoding) from the specified file.

public static X509Certificate2 LoadPkcs12(byte[] data, string password, X509KeyStorageFlags keyStorageFlags = 0, Pkcs12LoaderLimits loaderLimits = null)

Loads the provided data as a PKCS#12 PFX and extracts a certificate.

public static X509Certificate2 LoadPkcs12(ReadOnlySpan<byte> data, ReadOnlySpan<char> password, X509KeyStorageFlags keyStorageFlags = 0, Pkcs12LoaderLimits loaderLimits = null)

Loads the provided data as a PKCS#12 PFX and extracts a certificate.

public static X509Certificate2Collection LoadPkcs12Collection(byte[] data, string password, X509KeyStorageFlags keyStorageFlags = 0, Pkcs12LoaderLimits loaderLimits = null)

Loads the provided data as a PKCS#12 PFX and returns a collection of all of the certificates therein.

public static X509Certificate2Collection LoadPkcs12Collection(ReadOnlySpan<byte> data, ReadOnlySpan<char> password, X509KeyStorageFlags keyStorageFlags = 0, Pkcs12LoaderLimits loaderLimits = null)

Loads the provided data as a PKCS#12 PFX and returns a collection of all of the certificates therein.

public static X509Certificate2Collection LoadPkcs12CollectionFromFile(string path, string password, X509KeyStorageFlags keyStorageFlags = 0, Pkcs12LoaderLimits loaderLimits = null)

Opens the specified file, reads the contents as a PKCS#12 PFX and extracts a certificate. Loads the provided data as a PKCS#12 PFX and returns a collection of all of the certificates therein.

public static X509Certificate2Collection LoadPkcs12CollectionFromFile(string path, ReadOnlySpan<char> password, X509KeyStorageFlags keyStorageFlags = 0, Pkcs12LoaderLimits loaderLimits = null)

Opens the specified file, reads the contents as a PKCS#12 PFX and extracts a certificate. Loads the provided data as a PKCS#12 PFX and returns a collection of all of the certificates therein.

public static X509Certificate2 LoadPkcs12FromFile(string path, string password, X509KeyStorageFlags keyStorageFlags = 0, Pkcs12LoaderLimits loaderLimits = null)

Opens the specified file, reads the contents as a PKCS#12 PFX and extracts a certificate.

public static X509Certificate2 LoadPkcs12FromFile(string path, ReadOnlySpan<char> password, X509KeyStorageFlags keyStorageFlags = 0, Pkcs12LoaderLimits loaderLimits = null)

Opens the specified file, reads the contents as a PKCS#12 PFX and extracts a certificate.