diff options
author | Wouter Tinus <win.acme.simple@gmail.com> | 2020-07-17 13:20:35 +0200 |
---|---|---|
committer | Wouter Tinus <win.acme.simple@gmail.com> | 2020-07-17 13:20:35 +0200 |
commit | 8f25cf58df2766cbd74333bf3d3870bbc2187c7e (patch) | |
tree | 6fd25a36a2982dab224263d516d1bd9f6ecb4b53 | |
parent | 489284e7d285b118e271f9c044a33377bbf16e3d (diff) | |
download | letsencrypt-win-simple-8f25cf58df2766cbd74333bf3d3870bbc2187c7e.zip letsencrypt-win-simple-8f25cf58df2766cbd74333bf3d3870bbc2187c7e.tar.gz letsencrypt-win-simple-8f25cf58df2766cbd74333bf3d3870bbc2187c7e.tar.bz2 |
use more async I/O apis
-rw-r--r-- | src/main.lib/Clients/Acme/AcmeClient.cs | 2 | ||||
-rw-r--r-- | src/main.lib/Clients/AcmeDnsClient.cs | 2 | ||||
-rw-r--r-- | src/main.lib/Plugins/StorePlugins/CentralSsl/CentralSsl.cs | 5 | ||||
-rw-r--r-- | src/main.lib/Plugins/StorePlugins/PemFiles/PemFiles.cs | 11 | ||||
-rw-r--r-- | src/main.lib/Plugins/StorePlugins/PfxFile/PfxFile.cs | 5 | ||||
-rw-r--r-- | src/main.lib/Services/CertificateService.cs | 6 |
6 files changed, 14 insertions, 17 deletions
diff --git a/src/main.lib/Clients/Acme/AcmeClient.cs b/src/main.lib/Clients/Acme/AcmeClient.cs index 7ae6281..e3a3091 100644 --- a/src/main.lib/Clients/Acme/AcmeClient.cs +++ b/src/main.lib/Clients/Acme/AcmeClient.cs @@ -249,7 +249,7 @@ namespace PKISharp.WACS.Clients.Acme KeyExport = client.Signer.Export(),
};
AccountSigner = accountKey;
- File.WriteAllText(AccountPath, JsonConvert.SerializeObject(account));
+ await File.WriteAllTextAsync(AccountPath, JsonConvert.SerializeObject(account));
}
catch (Exception ex)
{
diff --git a/src/main.lib/Clients/AcmeDnsClient.cs b/src/main.lib/Clients/AcmeDnsClient.cs index 8c885f6..03cf733 100644 --- a/src/main.lib/Clients/AcmeDnsClient.cs +++ b/src/main.lib/Clients/AcmeDnsClient.cs @@ -81,7 +81,7 @@ namespace PKISharp.WACS.Clients } if (await VerifyRegistration(domain, newReg.Fulldomain, interactive)) { - File.WriteAllText(FileForDomain(domain), JsonConvert.SerializeObject(newReg)); + await File.WriteAllTextAsync(FileForDomain(domain), JsonConvert.SerializeObject(newReg)); return true; } } diff --git a/src/main.lib/Plugins/StorePlugins/CentralSsl/CentralSsl.cs b/src/main.lib/Plugins/StorePlugins/CentralSsl/CentralSsl.cs index a9e3a48..7bc444b 100644 --- a/src/main.lib/Plugins/StorePlugins/CentralSsl/CentralSsl.cs +++ b/src/main.lib/Plugins/StorePlugins/CentralSsl/CentralSsl.cs @@ -62,7 +62,7 @@ namespace PKISharp.WACS.Plugins.StorePlugins private string PathForIdentifier(string identifier) => Path.Combine(_path, $"{identifier.Replace("*", "_")}.pfx"); - public Task Save(CertificateInfo input) + public async Task Save(CertificateInfo input) { _log.Information("Copying certificate to the CentralSsl store"); foreach (var identifier in input.SanNames) @@ -76,7 +76,7 @@ namespace PKISharp.WACS.Plugins.StorePlugins input.Certificate }; collection.AddRange(input.Chain.ToArray()); - File.WriteAllBytes(dest, collection.Export(X509ContentType.Pfx, _password)); + await File.WriteAllBytesAsync(dest, collection.Export(X509ContentType.Pfx, _password)); } catch (Exception ex) { @@ -89,7 +89,6 @@ namespace PKISharp.WACS.Plugins.StorePlugins Name = CentralSslOptions.PluginName, Path = _path }); - return Task.CompletedTask; } public Task Delete(CertificateInfo input) diff --git a/src/main.lib/Plugins/StorePlugins/PemFiles/PemFiles.cs b/src/main.lib/Plugins/StorePlugins/PemFiles/PemFiles.cs index 97f1d86..052a4b2 100644 --- a/src/main.lib/Plugins/StorePlugins/PemFiles/PemFiles.cs +++ b/src/main.lib/Plugins/StorePlugins/PemFiles/PemFiles.cs @@ -50,7 +50,7 @@ namespace PKISharp.WACS.Plugins.StorePlugins } } - public Task Save(CertificateInfo input) + public async Task Save(CertificateInfo input) { _log.Information("Exporting .pem files to {folder}", _path); @@ -62,7 +62,7 @@ namespace PKISharp.WACS.Plugins.StorePlugins // Base certificate var certificateExport = input.Certificate.Export(X509ContentType.Cert); var exportString = _pemService.GetPem("CERTIFICATE", certificateExport); - File.WriteAllText(Path.Combine(_path, $"{name}-crt.pem"), exportString); + await File.WriteAllTextAsync(Path.Combine(_path, $"{name}-crt.pem"), exportString); // Rest of the chain foreach (var chainCertificate in input.Chain) @@ -77,7 +77,7 @@ namespace PKISharp.WACS.Plugins.StorePlugins } // Save complete chain - File.WriteAllText(Path.Combine(_path, $"{name}-chain.pem"), exportString); + await File.WriteAllTextAsync(Path.Combine(_path, $"{name}-chain.pem"), exportString); if (!input.StoreInfo.ContainsKey(GetType())) { input.StoreInfo.Add(GetType(), @@ -97,7 +97,7 @@ namespace PKISharp.WACS.Plugins.StorePlugins if (alias == null) { _log.Warning("No key entries found"); - return Task.CompletedTask; + return; } var entry = store.GetKey(alias); var key = entry.Key; @@ -107,7 +107,7 @@ namespace PKISharp.WACS.Plugins.StorePlugins } if (!string.IsNullOrEmpty(pkPem)) { - File.WriteAllText(Path.Combine(_path, $"{name}-key.pem"), pkPem); + await File.WriteAllTextAsync(Path.Combine(_path, $"{name}-key.pem"), pkPem); } else { @@ -123,7 +123,6 @@ namespace PKISharp.WACS.Plugins.StorePlugins { _log.Error(ex, "Error exporting .pem files to folder"); } - return Task.CompletedTask; } public Task Delete(CertificateInfo input) => Task.CompletedTask; diff --git a/src/main.lib/Plugins/StorePlugins/PfxFile/PfxFile.cs b/src/main.lib/Plugins/StorePlugins/PfxFile/PfxFile.cs index 8636eca..03ca169 100644 --- a/src/main.lib/Plugins/StorePlugins/PfxFile/PfxFile.cs +++ b/src/main.lib/Plugins/StorePlugins/PfxFile/PfxFile.cs @@ -40,7 +40,7 @@ namespace PKISharp.WACS.Plugins.StorePlugins private string PathForIdentifier(string identifier) => Path.Combine(_path, $"{identifier.Replace("*", "_")}.pfx"); - public Task Save(CertificateInfo input) + public async Task Save(CertificateInfo input) { _log.Information("Copying certificate to the pfx folder"); var dest = PathForIdentifier(input.CommonName); @@ -51,7 +51,7 @@ namespace PKISharp.WACS.Plugins.StorePlugins input.Certificate }; collection.AddRange(input.Chain.ToArray()); - File.WriteAllBytes(dest, collection.Export(X509ContentType.Pfx, _password)); + await File.WriteAllBytesAsync(dest, collection.Export(X509ContentType.Pfx, _password)); } catch (Exception ex) { @@ -63,7 +63,6 @@ namespace PKISharp.WACS.Plugins.StorePlugins Name = PfxFileOptions.PluginName, Path = _path }); - return Task.CompletedTask; } public Task Delete(CertificateInfo input) => Task.CompletedTask; diff --git a/src/main.lib/Services/CertificateService.cs b/src/main.lib/Services/CertificateService.cs index 949c9f5..ad2f0bf 100644 --- a/src/main.lib/Services/CertificateService.cs +++ b/src/main.lib/Services/CertificateService.cs @@ -325,7 +325,7 @@ namespace PKISharp.WACS.Services order.Target.CsrBytes = csr.GetDerEncoded();
order.Target.PrivateKey = keySet.Private;
var csrPath = GetPath(order.Renewal, $"-{cacheKey}{CsrPostFix}");
- File.WriteAllText(csrPath, _pemService.GetPem("CERTIFICATE REQUEST", order.Target.CsrBytes));
+ await File.WriteAllTextAsync(csrPath, _pemService.GetPem("CERTIFICATE REQUEST", order.Target.CsrBytes));
_log.Debug("CSR stored at {path} in certificate cache folder {folder}", Path.GetFileName(csrPath), Path.GetDirectoryName(csrPath));
}
@@ -408,7 +408,7 @@ namespace PKISharp.WACS.Services ClearCache(order.Renewal, postfix: $"*{PfxPostFix}");
ClearCache(order.Renewal, postfix: $"*{PfxPostFixLegacy}");
- File.WriteAllBytes(pfxFileInfo.FullName, tempPfx.Export(X509ContentType.Pfx, order.Renewal.PfxPassword?.Value));
+ await File.WriteAllBytesAsync(pfxFileInfo.FullName, tempPfx.Export(X509ContentType.Pfx, order.Renewal.PfxPassword?.Value));
_log.Debug("Certificate written to cache file {path} in certificate cache folder {folder}. It will be " +
"reused when renewing within {x} day(s) as long as the Target and Csr parameters remain the same and " +
"the --force switch is not used.",
@@ -432,7 +432,7 @@ namespace PKISharp.WACS.Services {
newVersion.FriendlyName = friendlyName;
tempPfx[certIndex] = newVersion;
- File.WriteAllBytes(pfxFileInfo.FullName, tempPfx.Export(X509ContentType.Pfx, order.Renewal.PfxPassword?.Value));
+ await File.WriteAllBytesAsync(pfxFileInfo.FullName, tempPfx.Export(X509ContentType.Pfx, order.Renewal.PfxPassword?.Value));
newVersion.Dispose();
}
}
|