summaryrefslogtreecommitdiffstats
path: root/src/main.lib/Services/Legacy
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.lib/Services/Legacy')
-rw-r--r--src/main.lib/Services/Legacy/BaseLegacyRenewalService.cs13
-rw-r--r--src/main.lib/Services/Legacy/CompatibleAzureDnsOptions.cs10
-rw-r--r--src/main.lib/Services/Legacy/FileLegacyRenewalService.cs2
-rw-r--r--src/main.lib/Services/Legacy/Importer.cs21
-rw-r--r--src/main.lib/Services/Legacy/LegacyAzureDnsOptions.cs10
-rw-r--r--src/main.lib/Services/Legacy/LegacyCredentials.cs4
-rw-r--r--src/main.lib/Services/Legacy/LegacyScheduledRenewal.cs6
-rw-r--r--src/main.lib/Services/Legacy/LegacySettingsService.cs24
-rw-r--r--src/main.lib/Services/Legacy/RegistryLegacyRenewalService.cs8
9 files changed, 57 insertions, 41 deletions
diff --git a/src/main.lib/Services/Legacy/BaseLegacyRenewalService.cs b/src/main.lib/Services/Legacy/BaseLegacyRenewalService.cs
index a09830e..3c0220f 100644
--- a/src/main.lib/Services/Legacy/BaseLegacyRenewalService.cs
+++ b/src/main.lib/Services/Legacy/BaseLegacyRenewalService.cs
@@ -10,8 +10,8 @@ namespace PKISharp.WACS.Services.Legacy
internal abstract class BaseLegacyRenewalService : ILegacyRenewalService
{
internal ILogService _log;
- internal List<LegacyScheduledRenewal> _renewalsCache;
- internal string _configPath = null;
+ internal List<LegacyScheduledRenewal>? _renewalsCache;
+ internal string? _configPath = null;
public BaseLegacyRenewalService(
LegacySettingsService settings,
@@ -28,7 +28,7 @@ namespace PKISharp.WACS.Services.Legacy
/// </summary>
/// <param name="BaseUri"></param>
/// <returns></returns>
- internal abstract string[] RenewalsRaw { get; }
+ internal abstract string[]? RenewalsRaw { get; }
/// <summary>
/// Parse renewals from store
@@ -41,7 +41,10 @@ namespace PKISharp.WACS.Services.Legacy
var list = new List<LegacyScheduledRenewal>();
if (read != null)
{
- list.AddRange(read.Select(x => Load(x)).Where(x => x != null));
+ list.AddRange(
+ read.Select(x => Load(x)).
+ Where(x => x != null).
+ OfType<LegacyScheduledRenewal>());
}
_renewalsCache = list;
}
@@ -54,7 +57,7 @@ namespace PKISharp.WACS.Services.Legacy
/// <param name="renewal"></param>
/// <param name="path"></param>
/// <returns></returns>
- private LegacyScheduledRenewal Load(string renewal)
+ private LegacyScheduledRenewal? Load(string renewal)
{
LegacyScheduledRenewal result;
try
diff --git a/src/main.lib/Services/Legacy/CompatibleAzureDnsOptions.cs b/src/main.lib/Services/Legacy/CompatibleAzureDnsOptions.cs
index a45a5ee..4c2b05e 100644
--- a/src/main.lib/Services/Legacy/CompatibleAzureDnsOptions.cs
+++ b/src/main.lib/Services/Legacy/CompatibleAzureDnsOptions.cs
@@ -13,13 +13,13 @@ namespace PKISharp.WACS.Services.Legacy
[Plugin("aa57b028-45fb-4aca-9cac-a63d94c76b4a")]
internal class CompatibleAzureOptions : ValidationPluginOptions, IIgnore
{
- public string ClientId { get; set; }
- public string ResourceGroupName { get; set; }
+ public string? ClientId { get; set; }
+ public string? ResourceGroupName { get; set; }
[JsonProperty(propertyName: "SecretSafe")]
- public ProtectedString Secret { get; set; }
+ public ProtectedString? Secret { get; set; }
- public string SubscriptionId { get; set; }
- public string TenantId { get; set; }
+ public string? SubscriptionId { get; set; }
+ public string? TenantId { get; set; }
}
} \ No newline at end of file
diff --git a/src/main.lib/Services/Legacy/FileLegacyRenewalService.cs b/src/main.lib/Services/Legacy/FileLegacyRenewalService.cs
index 40152a3..8ae5808 100644
--- a/src/main.lib/Services/Legacy/FileLegacyRenewalService.cs
+++ b/src/main.lib/Services/Legacy/FileLegacyRenewalService.cs
@@ -14,7 +14,7 @@ namespace PKISharp.WACS.Services.Legacy
private string FileName => Path.Combine(_configPath, _renewalsKey);
- internal override string[] RenewalsRaw
+ internal override string[]? RenewalsRaw
{
get
{
diff --git a/src/main.lib/Services/Legacy/Importer.cs b/src/main.lib/Services/Legacy/Importer.cs
index 32b5ac8..10c2268 100644
--- a/src/main.lib/Services/Legacy/Importer.cs
+++ b/src/main.lib/Services/Legacy/Importer.cs
@@ -173,7 +173,7 @@ namespace PKISharp.WACS.Services.Legacy
{
CopyWebConfig = legacy.Binding.IIS == true,
Path = legacy.Binding.WebRootPath,
- Credential = new NetworkCredentialOptions(legacy.Binding.HttpFtpOptions.UserName, legacy.Binding.HttpFtpOptions.Password)
+ Credential = new NetworkCredentialOptions(legacy.Binding.HttpFtpOptions?.UserName, legacy.Binding.HttpFtpOptions.Password)
};
break;
case "http-01.sftp":
@@ -181,16 +181,22 @@ namespace PKISharp.WACS.Services.Legacy
{
CopyWebConfig = legacy.Binding.IIS == true,
Path = legacy.Binding.WebRootPath,
- Credential = new NetworkCredentialOptions(legacy.Binding.HttpFtpOptions.UserName, legacy.Binding.HttpFtpOptions.Password)
+ Credential = new NetworkCredentialOptions(legacy.Binding.HttpFtpOptions?.UserName, legacy.Binding.HttpFtpOptions.Password)
};
break;
case "http-01.webdav":
- ret.ValidationPluginOptions = new http.WebDavOptions()
+ var options = new http.WebDavOptions()
{
CopyWebConfig = legacy.Binding.IIS == true,
- Path = legacy.Binding.WebRootPath,
- Credential = new NetworkCredentialOptions(legacy.Binding.HttpWebDavOptions.UserName, legacy.Binding.HttpWebDavOptions.Password)
+ Path = legacy.Binding.WebRootPath
};
+ if (legacy.Binding.HttpWebDavOptions != null)
+ {
+ options.Credential = new NetworkCredentialOptions(
+ legacy.Binding.HttpWebDavOptions.UserName,
+ legacy.Binding.HttpWebDavOptions.Password);
+ }
+ ret.ValidationPluginOptions = options;
break;
case "tls-sni-01.iis":
_log.Warning("TLS-SNI-01 validation was removed from ACMEv2, changing to SelfHosting. Note that this requires port 80 to be public rather than port 443.");
@@ -276,7 +282,10 @@ namespace PKISharp.WACS.Services.Legacy
case "iisftp":
ret.InstallationPluginOptions.Add(new install.IISFtpOptions()
{
- SiteId = legacy.Binding.FtpSiteId.Value
+ SiteId = legacy.Binding.FtpSiteId ??
+ legacy.Binding.InstallationSiteId ??
+ legacy.Binding.SiteId ??
+ 0
});
break;
case "manual":
diff --git a/src/main.lib/Services/Legacy/LegacyAzureDnsOptions.cs b/src/main.lib/Services/Legacy/LegacyAzureDnsOptions.cs
index de299a0..75a1794 100644
--- a/src/main.lib/Services/Legacy/LegacyAzureDnsOptions.cs
+++ b/src/main.lib/Services/Legacy/LegacyAzureDnsOptions.cs
@@ -2,10 +2,10 @@
{
internal class LegacyAzureDnsOptions
{
- public string ClientId { get; set; }
- public string ResourceGroupName { get; set; }
- public string Secret { get; set; }
- public string SubscriptionId { get; set; }
- public string TenantId { get; set; }
+ public string? ClientId { get; set; }
+ public string? ResourceGroupName { get; set; }
+ public string? Secret { get; set; }
+ public string? SubscriptionId { get; set; }
+ public string? TenantId { get; set; }
}
}
diff --git a/src/main.lib/Services/Legacy/LegacyCredentials.cs b/src/main.lib/Services/Legacy/LegacyCredentials.cs
index 535cf4e..2203049 100644
--- a/src/main.lib/Services/Legacy/LegacyCredentials.cs
+++ b/src/main.lib/Services/Legacy/LegacyCredentials.cs
@@ -2,7 +2,7 @@
{
internal class LegacyCredentials
{
- public string UserName { get; set; }
- public string Password { get; set; }
+ public string? UserName { get; set; }
+ public string? Password { get; set; }
}
}
diff --git a/src/main.lib/Services/Legacy/LegacyScheduledRenewal.cs b/src/main.lib/Services/Legacy/LegacyScheduledRenewal.cs
index 2c22b99..aefa5d5 100644
--- a/src/main.lib/Services/Legacy/LegacyScheduledRenewal.cs
+++ b/src/main.lib/Services/Legacy/LegacyScheduledRenewal.cs
@@ -42,17 +42,17 @@ namespace PKISharp.WACS.Services.Legacy
/// <summary>
/// Name of the plugins to use for validation, in order of execution
/// </summary>
- public List<string> InstallationPluginNames { get; set; }
+ public List<string>? InstallationPluginNames { get; set; }
/// <summary>
/// Script to run on succesful renewal
/// </summary>
- public string Script { get; set; }
+ public string? Script { get; set; }
/// <summary>
/// Parameters for script
/// </summary>e
- public string ScriptParameters { get; set; }
+ public string? ScriptParameters { get; set; }
/// <summary>
/// Warmup target website (applies to http-01 validation)
diff --git a/src/main.lib/Services/Legacy/LegacySettingsService.cs b/src/main.lib/Services/Legacy/LegacySettingsService.cs
index 4c55380..71be4c3 100644
--- a/src/main.lib/Services/Legacy/LegacySettingsService.cs
+++ b/src/main.lib/Services/Legacy/LegacySettingsService.cs
@@ -13,17 +13,17 @@ namespace PKISharp.WACS.Host.Services.Legacy
{
private readonly ILogService _log;
- public UiSettings UI { get; private set; }
- public AcmeSettings Acme { get; private set; }
- public ProxySettings Proxy { get; private set; }
- public CacheSettings Cache { get; private set; }
- public ScheduledTaskSettings ScheduledTask { get; private set; }
- public NotificationSettings Notification { get; private set; }
- public SecuritySettings Security { get; private set; }
- public ScriptSettings Script { get; private set; }
- public ClientSettings Client { get; private set; }
- public ValidationSettings Validation { get; private set; }
- public StoreSettings Store { get; private set; }
+ public ClientSettings Client { get; private set; } = new ClientSettings();
+ public UiSettings UI { get; private set; } = new UiSettings();
+ public AcmeSettings Acme { get; private set; } = new AcmeSettings();
+ public ProxySettings Proxy { get; private set; } = new ProxySettings();
+ public CacheSettings Cache { get; private set; } = new CacheSettings();
+ public ScheduledTaskSettings ScheduledTask { get; private set; } = new ScheduledTaskSettings();
+ public NotificationSettings Notification { get; private set; } = new NotificationSettings();
+ public SecuritySettings Security { get; private set; } = new SecuritySettings();
+ public ScriptSettings Script { get; private set; } = new ScriptSettings();
+ public ValidationSettings Validation { get; private set; } = new ValidationSettings();
+ public StoreSettings Store { get; private set; } = new StoreSettings();
public string ExePath { get; private set; }
public List<string> ClientNames { get; private set; }
@@ -83,7 +83,7 @@ namespace PKISharp.WACS.Host.Services.Legacy
CreateConfigPath(main, userRoot);
}
- private void CreateConfigPath(MainArguments options, string userRoot)
+ private void CreateConfigPath(MainArguments options, string? userRoot)
{
var configRoot = "";
if (!string.IsNullOrEmpty(userRoot))
diff --git a/src/main.lib/Services/Legacy/RegistryLegacyRenewalService.cs b/src/main.lib/Services/Legacy/RegistryLegacyRenewalService.cs
index f34dd91..2f36fa3 100644
--- a/src/main.lib/Services/Legacy/RegistryLegacyRenewalService.cs
+++ b/src/main.lib/Services/Legacy/RegistryLegacyRenewalService.cs
@@ -1,7 +1,7 @@
using Microsoft.Win32;
using PKISharp.WACS.Configuration;
using PKISharp.WACS.Host.Services.Legacy;
-using System.Linq;
+using System;
namespace PKISharp.WACS.Services.Legacy
{
@@ -18,6 +18,10 @@ namespace PKISharp.WACS.Services.Legacy
LegacySettingsService settings) :
base(settings, log)
{
+ if (main.BaseUri == null)
+ {
+ throw new InvalidOperationException("Missing main.BaseUri");
+ }
_baseUri = main.BaseUri;
_hive = $"HKEY_CURRENT_USER{Key}";
if (RenewalsRaw == null)
@@ -29,6 +33,6 @@ namespace PKISharp.WACS.Services.Legacy
private string Key => $"\\Software\\{_clientName}\\{_baseUri}";
- internal override string[] RenewalsRaw => Registry.GetValue(_hive, _renewalsKey, null) as string[];
+ internal override string[] RenewalsRaw => Registry.GetValue(_hive, _renewalsKey, null) as string[] ?? new string[] { };
}
}