diff --git a/src/Configuration/OpcUaAppConfigFactory.cs b/src/Configuration/OpcUaAppConfigFactory.cs index 049e687f..e4d45503 100644 --- a/src/Configuration/OpcUaAppConfigFactory.cs +++ b/src/Configuration/OpcUaAppConfigFactory.cs @@ -576,7 +576,7 @@ private async Task RemoveCertificatesAsync(List thumbprintsToRemov try { _logger.LogInformation("Starting to remove certificate(s) from trusted peer and trusted issuer store"); - using ICertificateStore trustedStore = CertificateStoreIdentifier.OpenStore(_config.OpcUa.ApplicationConfiguration.SecurityConfiguration.TrustedPeerCertificates.StorePath); + using ICertificateStore trustedStore = _config.OpcUa.ApplicationConfiguration.SecurityConfiguration.TrustedPeerCertificates.OpenStore(); foreach (var thumbprint in thumbprintsToRemove) { var certToRemove = await trustedStore.FindByThumbprint(thumbprint).ConfigureAwait(false); @@ -602,7 +602,7 @@ private async Task RemoveCertificatesAsync(List thumbprintsToRemov // search the trusted issuer store and remove certificates with a specified thumbprint try { - using ICertificateStore issuerStore = CertificateStoreIdentifier.OpenStore(_config.OpcUa.ApplicationConfiguration.SecurityConfiguration.TrustedIssuerCertificates.StorePath); + using ICertificateStore issuerStore = _config.OpcUa.ApplicationConfiguration.SecurityConfiguration.TrustedPeerCertificates.OpenStore(); foreach (var thumbprint in thumbprintsToRemove) { var certToRemove = await issuerStore.FindByThumbprint(thumbprint).ConfigureAwait(false); @@ -685,7 +685,7 @@ private async Task AddCertificatesAsync( { try { - using ICertificateStore issuerStore = CertificateStoreIdentifier.OpenStore(_config.OpcUa.ApplicationConfiguration.SecurityConfiguration.TrustedIssuerCertificates.StorePath); + using ICertificateStore issuerStore = _config.OpcUa.ApplicationConfiguration.SecurityConfiguration.TrustedPeerCertificates.OpenStore(); foreach (var certificateToAdd in certificatesToAdd) { try @@ -710,7 +710,7 @@ private async Task AddCertificatesAsync( { try { - using ICertificateStore trustedStore = CertificateStoreIdentifier.OpenStore(_config.OpcUa.ApplicationConfiguration.SecurityConfiguration.TrustedPeerCertificates.StorePath); + using ICertificateStore trustedStore = _config.OpcUa.ApplicationConfiguration.SecurityConfiguration.TrustedPeerCertificates.OpenStore(); foreach (var certificateToAdd in certificatesToAdd) { try @@ -777,7 +777,7 @@ private async Task UpdateCrlAsync(string newCrlBase64String, string newCrl } // check if CRL was signed by a trusted peer cert - using (ICertificateStore trustedStore = CertificateStoreIdentifier.OpenStore(_config.OpcUa.ApplicationConfiguration.SecurityConfiguration.TrustedPeerCertificates.StorePath)) + using (ICertificateStore trustedStore = _config.OpcUa.ApplicationConfiguration.SecurityConfiguration.TrustedPeerCertificates.OpenStore()) { bool trustedCrlIssuer = false; var trustedCertificates = await trustedStore.Enumerate().ConfigureAwait(false); @@ -834,7 +834,7 @@ private async Task UpdateCrlAsync(string newCrlBase64String, string newCrl } // check if CRL was signed by a trusted issuer cert - using (ICertificateStore issuerStore = CertificateStoreIdentifier.OpenStore(_config.OpcUa.ApplicationConfiguration.SecurityConfiguration.TrustedIssuerCertificates.StorePath)) + using (ICertificateStore issuerStore = _config.OpcUa.ApplicationConfiguration.SecurityConfiguration.TrustedPeerCertificates.OpenStore()) { bool trustedCrlIssuer = false; var issuerCertificates = await issuerStore.Enumerate().ConfigureAwait(false); @@ -993,7 +993,7 @@ private async Task UpdateApplicationCertificateAsync( var certValidator = new CertificateValidator(); var verificationTrustList = new CertificateTrustList(); var verificationCollection = new CertificateIdentifierCollection(); - using (ICertificateStore issuerStore = CertificateStoreIdentifier.OpenStore(_config.OpcUa.ApplicationConfiguration.SecurityConfiguration.TrustedIssuerCertificates.StorePath)) + using (ICertificateStore issuerStore = _config.OpcUa.ApplicationConfiguration.SecurityConfiguration.TrustedPeerCertificates.OpenStore()) { var certs = await issuerStore.Enumerate().ConfigureAwait(false); foreach (var cert in certs) @@ -1001,7 +1001,7 @@ private async Task UpdateApplicationCertificateAsync( verificationCollection.Add(new CertificateIdentifier(cert)); } } - using (ICertificateStore trustedStore = CertificateStoreIdentifier.OpenStore(_config.OpcUa.ApplicationConfiguration.SecurityConfiguration.TrustedPeerCertificates.StorePath)) + using (ICertificateStore trustedStore = _config.OpcUa.ApplicationConfiguration.SecurityConfiguration.TrustedPeerCertificates.OpenStore()) { var certs = await trustedStore.Enumerate().ConfigureAwait(false); foreach (var cert in certs) @@ -1094,7 +1094,7 @@ private async Task UpdateApplicationCertificateAsync( } // remove the existing and add the new application cert - using (ICertificateStore appStore = CertificateStoreIdentifier.OpenStore(_config.OpcUa.ApplicationConfiguration.SecurityConfiguration.ApplicationCertificate.StorePath)) + using (ICertificateStore appStore = _config.OpcUa.ApplicationConfiguration.SecurityConfiguration.TrustedPeerCertificates.OpenStore()) { _logger.LogInformation("Remove the existing application certificate"); try diff --git a/src/FlatDirectoryCertificateStore.cs b/src/FlatDirectoryCertificateStore.cs index 4cf6eaf7..07b87154 100644 --- a/src/FlatDirectoryCertificateStore.cs +++ b/src/FlatDirectoryCertificateStore.cs @@ -49,6 +49,8 @@ public FlatDirectoryCertificateStore() /// public bool SupportsCRLs => _innerStore.SupportsCRLs; + public bool NoPrivateKeys => _innerStore.NoPrivateKeys; + /// public void Dispose() { @@ -81,6 +83,12 @@ public Task Add(X509Certificate2 certificate, string password = null) return _innerStore.Add(certificate, password); } + /// + public Task AddRejected(X509Certificate2Collection certificates, int maxCertificates) + { + return _innerStore.AddRejected(certificates, maxCertificates); + } + /// public Task Delete(string thumbprint) { diff --git a/src/opc-plc.csproj b/src/opc-plc.csproj index cef5e731..51f2e2f5 100644 --- a/src/opc-plc.csproj +++ b/src/opc-plc.csproj @@ -43,8 +43,8 @@ - - + + @@ -53,8 +53,8 @@ - - + + diff --git a/tests/opc-plc-tests.csproj b/tests/opc-plc-tests.csproj index adf9bb97..658faa58 100644 --- a/tests/opc-plc-tests.csproj +++ b/tests/opc-plc-tests.csproj @@ -19,16 +19,16 @@ - - - + + + - - - + + + diff --git a/version.json b/version.json index bc451442..32fd5ac0 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "2.12.23", + "version": "2.12.24", "versionHeightOffset": -1, "publicReleaseRefSpec": [ "^refs/heads/main$",