Class AbstractCachedCertificateLoader
- Namespace
- ComponentSpace.Saml2.Certificates
- Assembly
- ComponentSpace.Saml2.dll
The cached certificate loader loads X.509 certificates.
Certificates are cached in memory for performance.
public abstract class AbstractCachedCertificateLoader : ICertificateLoader
- Inheritance
-
AbstractCachedCertificateLoader
- Implements
- Derived
- Inherited Members
Constructors
AbstractCachedCertificateLoader(ICertificateLoader, IOptionsMonitor<CertificateCacheOptions>, IMemoryCache, ILoggerFactory)
Initializes a new instance of the CachedCertificateLoader class.
public AbstractCachedCertificateLoader(ICertificateLoader certificateLoader, IOptionsMonitor<CertificateCacheOptions> certificateCacheOptions, IMemoryCache memoryCache, ILoggerFactory loggerFactory)
Parameters
certificateLoaderICertificateLoaderThe certificate loader.
certificateCacheOptionsIOptionsMonitor<CertificateCacheOptions>The certificate cache options.
memoryCacheIMemoryCacheThe memory cache used to store certificates.
loggerFactoryILoggerFactoryThe 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
certificateBytesbyte[]The certificate bytes.
certificatePasswordstringThe certificate password or
nullif 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.
Certificates are cached in memory for performance.
public virtual Task<X509Certificate2> LoadCertificateFromFileAsync(string certificateFile, string certificatePassword = null)
Parameters
certificateFilestringThe certificate file name.
certificatePasswordstringThe certificate file password or
nullif 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
certificateKeystringThe 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.
Certificates are cached in memory for performance.
public virtual Task<X509Certificate2> LoadCertificateFromStoreAsync(string storeName, StoreLocation storeLocation, X509FindType findType, object findValue)
Parameters
storeNamestringThe store name.
storeLocationStoreLocationThe store location.
findTypeX509FindTypeThe find type for searching the certificate store.
findValueobjectThe 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.
Certificates are cached in memory for performance.
public virtual Task<X509Certificate2> LoadCertificateFromStringAsync(string certificateString, string certificatePassword = null)
Parameters
certificateStringstringThe certificate base-64 encoded string.
certificatePasswordstringThe certificate password or
nullif 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.