diff --git a/src/Trash/Command/RadarrCommand.cs b/src/Trash/Command/RadarrCommand.cs index c3ef4862..f49dcc9d 100644 --- a/src/Trash/Command/RadarrCommand.cs +++ b/src/Trash/Command/RadarrCommand.cs @@ -28,10 +28,11 @@ public class RadarrCommand : ServiceCommand LoggingLevelSwitch loggingLevelSwitch, ILogJanitor logJanitor, ISettingsPersister settingsPersister, + ISettingsProvider settingsProvider, IConfigurationLoader configLoader, Func qualityUpdaterFactory, Func customFormatUpdaterFactory) - : base(log, loggingLevelSwitch, logJanitor, settingsPersister) + : base(log, loggingLevelSwitch, logJanitor, settingsPersister, settingsProvider) { _log = log; _configLoader = configLoader; diff --git a/src/Trash/Command/ServiceCommand.cs b/src/Trash/Command/ServiceCommand.cs index 53f3a529..0a78b0de 100644 --- a/src/Trash/Command/ServiceCommand.cs +++ b/src/Trash/Command/ServiceCommand.cs @@ -25,23 +25,30 @@ public abstract class ServiceCommand : ICommand, IServiceCommand private readonly LoggingLevelSwitch _loggingLevelSwitch; private readonly ILogJanitor _logJanitor; private readonly ISettingsPersister _settingsPersister; + private readonly ISettingsProvider _settingsProvider; protected ServiceCommand( ILogger log, LoggingLevelSwitch loggingLevelSwitch, ILogJanitor logJanitor, - ISettingsPersister settingsPersister) + ISettingsPersister settingsPersister, + ISettingsProvider settingsProvider) { _loggingLevelSwitch = loggingLevelSwitch; _logJanitor = logJanitor; _settingsPersister = settingsPersister; + _settingsProvider = settingsProvider; _log = log; } public async ValueTask ExecuteAsync(IConsole console) { + // Must happen first because everything can use the logger. SetupLogging(); + + // Has to happen right after logging because stuff below may use settings. LoadSettings(); + SetupHttp(); try @@ -122,7 +129,12 @@ public abstract class ServiceCommand : ICommand, IServiceCommand settings.JsonSerializer = new NewtonsoftJsonSerializer(jsonSettings); FlurlLogging.SetupLogging(settings, _log); - settings.HttpClientFactory = new UntrustedCertClientFactory(); + if (!_settingsProvider.Settings.EnableSslCertificateValidation) + { + _log.Warning( + "Security Risk: Certificate validation is being DISABLED because setting `enable_ssl_certificate_validation` is set to `false`"); + settings.HttpClientFactory = new UntrustedCertClientFactory(); + } }); } diff --git a/src/Trash/Command/SonarrCommand.cs b/src/Trash/Command/SonarrCommand.cs index 16efebaa..f38fbe72 100644 --- a/src/Trash/Command/SonarrCommand.cs +++ b/src/Trash/Command/SonarrCommand.cs @@ -28,10 +28,11 @@ public class SonarrCommand : ServiceCommand LoggingLevelSwitch loggingLevelSwitch, ILogJanitor logJanitor, ISettingsPersister settingsPersister, + ISettingsProvider settingsProvider, IConfigurationLoader configLoader, Func profileUpdaterFactory, Func qualityUpdaterFactory) - : base(log, loggingLevelSwitch, logJanitor, settingsPersister) + : base(log, loggingLevelSwitch, logJanitor, settingsPersister, settingsProvider) { _log = log; _configLoader = configLoader;