2using System.Collections.Generic;
4using System.Security.Cryptography.X509Certificates;
6using System.Text.Json.Serialization;
7using System.Threading.Tasks;
19 public Dictionary<string, bool>
Settings {
get;
set; } =
new Dictionary<string, bool>
21 [
"trust.enable"] =
true,
22 [
"selfsign.enable"] =
true,
83 throw new InvalidOperationException($
"The ID '{id}' is protected and cannot be modified.");
110 if (prefixes ==
null || prefixes.Length == 0)
112 throw new ArgumentNullException(nameof(prefixes),
"Prefixes cannot be null or empty.");
125 TrustedRootCA[
"sapteam:rootca"] = SAPTeamCertificates.RootCA;
126 IntermediateCA[
"sapteam:packages"] = SAPTeamCertificates.PackagesIntermediateCA;
147 id = !
string.IsNullOrEmpty(
id) ? id : certificate.Thumbprint.ToLowerInvariant()[^6..];
153 byte[] data = certificateStore == CertificateStore.IssuedCertificates ? certificate.Export(X509ContentType.Pfx) : certificate.Export(X509ContentType.Cert);
155 switch (certificateStore)
167 throw new ArgumentOutOfRangeException(nameof(certificateStore), certificateStore,
null);
185 X509Certificate2Collection certificates =
new X509Certificate2Collection();
187 switch (certificateStore)
208 throw new ArgumentOutOfRangeException(nameof(certificateStore), certificateStore,
null);
229 switch (certificateStore)
241 throw new ArgumentOutOfRangeException(nameof(certificateStore), certificateStore,
null);
244 return certificateStore == CertificateStore.IssuedCertificates
245 ? CertificateUtilities.ImportPFX(data).Single()
246 : CertificateUtilities.Import(data);
271 switch (certificateStore)
283 throw new ArgumentOutOfRangeException(nameof(certificateStore), certificateStore,
null);
Represents the configuration for the EasySign command provider.
byte?[] SelfSignedRootCA
Gets or sets the self-signed root CA certificate.
CommandProviderConfiguration()
Initializes a new instance of the CommandProviderConfiguration class.
void AddSAPTeamCertificates()
Adds the SAP Team certificates to the trusted root CA and intermediate CA stores and Locks the saptea...
void AddProtectedPrefix(params string[] prefixes)
Adds given prefixes to the list of Protected ID Prefixes.
Dictionary< string, byte[]> TrustedRootCA
Gets or sets the list of trusted root CA certificates.
bool IsProtected(string id)
Checks if the given ID starts with any of the protected prefixes.
string AddCertificate(CertificateStore certificateStore, X509Certificate2 certificate, string? id=null)
Adds a certificate to the specified certificate store.
X509Certificate2 LoadCertificate(CertificateStore certificateStore, string id)
Loads a certificate from the specified certificate store using the given ID.
string[] ProtectedPrefixes
Gets or sets the list of prefixes that should be protected from modification.
Dictionary< string, bool > Settings
Gets or sets the settings for the command provider.
CommandProviderConfiguration(string[] protectedPrefixes)
Initializes a new instance of the CommandProviderConfiguration class with the specified protected pre...
bool RemoveCertificate(CertificateStore certificateStore, string id)
Removes a certificate from the specified certificate store using the given ID.
void CheckProtectedPrefix(string id)
Checks if the given ID starts with any of the protected prefixes.
Dictionary< string, byte[]> IntermediateCA
Gets or sets the list of intermediate CA certificates.
X509Certificate2Collection LoadCertificates(CertificateStore certificateStore)
Loads all certificates from the specified certificate store.
Dictionary< string, byte[]> IssuedCertificates
Gets or sets the list of issued certificates by the self signing root CA.
CertificateStore
Enumeration of certificate stores in the CommandProviderConfiguration.