Show / Hide Table of Contents

Class AbstractCachedCertificateLoader

The cached certificate loader loads X.509 certificates.

Certificates are cached in memory for performance.

Inheritance
System.Object
AbstractCachedCertificateLoader
CachedCertificateLoader
Implements
ICertificateLoader
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: ComponentSpace.Saml2.Certificates
Assembly: ComponentSpace.Saml2.dll
Syntax
public abstract class AbstractCachedCertificateLoader : ICertificateLoader

Constructors

AbstractCachedCertificateLoader(ICertificateLoader, IOptionsMonitor<CertificateCacheOptions>, IMemoryCache, ILoggerFactory)

Initializes a new instance of the CachedCertificateLoader class.

Declaration
public AbstractCachedCertificateLoader(ICertificateLoader certificateLoader, IOptionsMonitor<CertificateCacheOptions> certificateCacheOptions, IMemoryCache memoryCache, ILoggerFactory loggerFactory)
Parameters
Type Name Description
ICertificateLoader certificateLoader

The certificate loader.

Microsoft.Extensions.Options.IOptionsMonitor<CertificateCacheOptions> certificateCacheOptions

The certificate cache options.

Microsoft.Extensions.Caching.Memory.IMemoryCache memoryCache

The memory cache used to store certificates.

Microsoft.Extensions.Logging.ILoggerFactory loggerFactory

The logger factory.

Methods

LoadCertificateFromBytesAsync(Byte[], String)

Loads an X.509 certificate from a byte array.

Declaration
public virtual Task<X509Certificate2> LoadCertificateFromBytesAsync(byte[] certificateBytes, string certificatePassword = null)
Parameters
Type Name Description
System.Byte[] certificateBytes

The certificate bytes.

System.String certificatePassword

The certificate password or null if none.

Returns
Type Description
System.Threading.Tasks.Task<System.Security.Cryptography.X509Certificates.X509Certificate2>

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

Exceptions
Type Condition
SamlException

Thrown when the X.509 certificates cannot be loaded.

LoadCertificateFromFileAsync(String, String)

Loads an X.509 certificate from the file system.

Certificates are cached in memory for performance.

Declaration
public virtual async Task<X509Certificate2> LoadCertificateFromFileAsync(string certificateFile, string certificatePassword = null)
Parameters
Type Name Description
System.String certificateFile

The certificate file name.

System.String certificatePassword

The certificate file password or null if none.

Returns
Type Description
System.Threading.Tasks.Task<System.Security.Cryptography.X509Certificates.X509Certificate2>

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

Exceptions
Type Condition
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.

Declaration
public virtual async Task<X509Certificate2> LoadCertificateFromKeyAsync(string certificateKey)
Parameters
Type Name Description
System.String certificateKey

The configuration key.

Returns
Type Description
System.Threading.Tasks.Task<System.Security.Cryptography.X509Certificates.X509Certificate2>

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

Exceptions
Type Condition
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.

Certificates are cached in memory for performance.

Declaration
public virtual async Task<X509Certificate2> LoadCertificateFromStoreAsync(string storeName, StoreLocation storeLocation, X509FindType findType, object findValue)
Parameters
Type Name Description
System.String storeName

The store name.

System.Security.Cryptography.X509Certificates.StoreLocation storeLocation

The store location.

System.Security.Cryptography.X509Certificates.X509FindType findType

The find type for searching the certificate store.

System.Object findValue

The find value for searching the certificate store.

Returns
Type Description
System.Threading.Tasks.Task<System.Security.Cryptography.X509Certificates.X509Certificate2>

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

Exceptions
Type Condition
SamlException

Thrown when the X.509 certificates cannot be loaded.

LoadCertificateFromStringAsync(String, String)

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

Certificates are cached in memory for performance.

Declaration
public virtual async Task<X509Certificate2> LoadCertificateFromStringAsync(string certificateString, string certificatePassword = null)
Parameters
Type Name Description
System.String certificateString

The certificate base-64 encoded string.

System.String certificatePassword

The certificate password or null if none.

Returns
Type Description
System.Threading.Tasks.Task<System.Security.Cryptography.X509Certificates.X509Certificate2>

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

Exceptions
Type Condition
SamlException

Thrown when the X.509 certificates cannot be loaded.

Implements

ICertificateLoader
In This Article
Back to top Copyright © ComponentSpace Pty Ltd 2017-2022. All rights reserved.