Table of Contents

Class CertificateLoader

Namespace
ComponentSpace.Saml2.Certificates
Assembly
ComponentSpace.Saml2.dll

The certificate loader loads X.509 certificates.

public class CertificateLoader : ICertificateLoader
Inheritance
CertificateLoader
Implements
Inherited Members

Constructors

CertificateLoader(IConfiguration, ILoggerFactory)

Initializes a new instance of the CertificateLoader class.

public CertificateLoader(IConfiguration configuration, ILoggerFactory loggerFactory)

Parameters

configuration IConfiguration

The configuration.

loggerFactory ILoggerFactory

The logger factory.

Methods

LoadCertificateFromBytesAsync(byte[], string)

Loads an X.509 certificate from a byte array.

public virtual Task<X509Certificate2> LoadCertificateFromBytesAsync(byte[] certificateBytes, string certificatePassword = null)

Parameters

certificateBytes byte[]

The certificate bytes.

certificatePassword string

The certificate password or null if none.

Returns

Task<X509Certificate2>

A task that represents the operation and returns the X.509 certificate.

Exceptions

SamlException

Thrown when the X.509 certificates cannot be loaded.

LoadCertificateFromFileAsync(string, string)

Loads an X.509 certificate from the file system.

public virtual Task<X509Certificate2> LoadCertificateFromFileAsync(string certificateFile, string certificatePassword = null)

Parameters

certificateFile string

The certificate file name.

certificatePassword string

The certificate file password or null if none.

Returns

Task<X509Certificate2>

A task that represents the operation and returns the X.509 certificate.

Exceptions

SamlException

Thrown when the X.509 certificates cannot be loaded.

LoadCertificateFromKeyAsync(string)

Loads an X.509 certificate from elsewhere in the configuration.

This may be used to retrieve certificates stored in an Azure key vault.

public virtual Task<X509Certificate2> LoadCertificateFromKeyAsync(string certificateKey)

Parameters

certificateKey string

The configuration key.

Returns

Task<X509Certificate2>

A task that represents the operation and returns the X.509 certificate.

Exceptions

SamlException

Thrown when the X.509 certificates cannot be loaded.

LoadCertificateFromStoreAsync(string, StoreLocation, X509FindType, object)

Loads an X.509 certificate from the Windows Certificate Store.

public virtual Task<X509Certificate2> LoadCertificateFromStoreAsync(string storeName, StoreLocation storeLocation, X509FindType findType, object findValue)

Parameters

storeName string

The store name.

storeLocation StoreLocation

The store location.

findType X509FindType

The find type for searching the certificate store.

findValue object

The find value for searching the certificate store.

Returns

Task<X509Certificate2>

A task that represents the operation and returns the X.509 certificate.

Exceptions

SamlException

Thrown when the X.509 certificates cannot be loaded.

LoadCertificateFromStringAsync(string, string)

Loads an X.509 certificate from a base-64 encoded string.

public virtual Task<X509Certificate2> LoadCertificateFromStringAsync(string certificateString, string certificatePassword = null)

Parameters

certificateString string

The certificate base-64 encoded string.

certificatePassword string

The certificate password or null if none.

Returns

Task<X509Certificate2>

A task that represents the operation and returns the X.509 certificate.

Exceptions

SamlException

Thrown when the X.509 certificates cannot be loaded.