Class X509CertificateLoader
- Namespace
- Arc4u.Security.Cryptography
- Assembly
- Arc4u.dll
The default IX509CertificateLoader: it searches the certificate stores of the machine or loads PEM files.
[Export(typeof(IX509CertificateLoader))]
public class X509CertificateLoader : IX509CertificateLoader
- Inheritance
-
X509CertificateLoader
- Implements
- Inherited Members
- Extension Methods
Constructors
X509CertificateLoader(ILogger<X509CertificateLoader>?)
Initializes a new instance of the X509CertificateLoader class.
public X509CertificateLoader(ILogger<X509CertificateLoader>? logger)
Parameters
loggerILogger<X509CertificateLoader>An optional logger used to trace missing files.
Methods
FindCertificate(CertificateFilePathInfo?)
Creates a certificate from PEM files.
public X509Certificate2 FindCertificate(CertificateFilePathInfo? certificateFilePathInfo)
Parameters
certificateFilePathInfoCertificateFilePathInfo
Returns
- X509Certificate2
The certificate, with its private key.
Exceptions
- ArgumentNullException
certificateFilePathInfois null.- FileNotFoundException
The public certificate file or the private key file does not exist.
FindCertificate(CertificateInfo)
Just a wrapper class to encapsultate the search of a certificate in the system based on the OS.
public X509Certificate2 FindCertificate(CertificateInfo certificateInfo)
Parameters
certificateInfoCertificateInfo
Returns
FindCertificate(IConfiguration, string)
Read the current section and identify if the section contains a CertificateStore entry. If yes, the Certificate will be retrieve based on the CertificateInfo object. If no CertificateStore section exists, the File is checked and a certificate will be created bqsed on the pem files (private and public keys).
public X509Certificate2? FindCertificate(IConfiguration configuration, string sectionName)
Parameters
configurationIConfigurationsectionNamestringThe name of the section if the IConfiguration
Returns
FindCertificate(string, X509FindType, StoreLocation, StoreName)
Find a certificate in the system: Certificate store for Windows or Keychain...
protected X509Certificate2 FindCertificate(string find, X509FindType findType = X509FindType.FindBySubjectName, StoreLocation location = StoreLocation.LocalMachine, StoreName name = StoreName.My)
Parameters
findstringThe certificate criteria to look for...
findTypeX509FindTypeX509FindType, default is FindBySubjectName
locationStoreLocationStoreLocation, default is LocalMachine
nameStoreNameStoreName, default is My
Returns
Exceptions
- KeyNotFoundException
No certificate is found!