summaryrefslogtreecommitdiffstats
path: root/src/main.lib/Plugins/StorePlugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.lib/Plugins/StorePlugins')
-rw-r--r--src/main.lib/Plugins/StorePlugins/CertificateStore/CertificateStore.cs24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/main.lib/Plugins/StorePlugins/CertificateStore/CertificateStore.cs b/src/main.lib/Plugins/StorePlugins/CertificateStore/CertificateStore.cs
index 53e28e5..2a3e711 100644
--- a/src/main.lib/Plugins/StorePlugins/CertificateStore/CertificateStore.cs
+++ b/src/main.lib/Plugins/StorePlugins/CertificateStore/CertificateStore.cs
@@ -208,25 +208,33 @@ namespace PKISharp.WACS.Plugins.StorePlugins
{
imStore = new X509Store(StoreName.CertificateAuthority, StoreLocation.LocalMachine);
imStore.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadWrite);
+ if (!imStore.IsOpen)
+ {
+ _log.Verbose("Unable to open intermediate certificate authority store");
+ imStore = new X509Store(_store.Name, StoreLocation.LocalMachine);
+ imStore.Open(OpenFlags.ReadWrite);
+ }
}
catch
{
_log.Warning("Error encountered while opening intermediate certificate store");
return;
}
- try
+
+ foreach (var cert in chain)
{
- foreach (var cert in chain)
+ try
{
- _log.Verbose("{sub} - {iss} ({thumb}) to intermediate certificate store", cert.Subject, cert.Issuer, cert.Thumbprint);
+ _log.Verbose("{sub} - {iss} ({thumb}) to store {store}", cert.Subject, cert.Issuer, cert.Thumbprint, imStore.Name);
imStore.Add(cert);
}
+ catch (Exception ex)
+ {
+ _log.Warning("Error saving certificate to store {store}: {message}", imStore.Name, ex.Message);
+ }
}
- catch (Exception ex)
- {
- _log.Error(ex, "Error saving certificate to intermediate store");
- }
- _log.Debug("Closing intermediate certificate store");
+
+ _log.Debug("Closing store {store}", imStore.Name);
imStore.Close();
}