fix: Check setting before disabling cert validation

Also add a warning log to make it clear to the user that certificate
validation has been disabled.
pull/47/head
Robert Dailey 3 years ago
parent 3d9dc185b1
commit 62c3e5c6a2

@ -28,10 +28,11 @@ public class RadarrCommand : ServiceCommand
LoggingLevelSwitch loggingLevelSwitch, LoggingLevelSwitch loggingLevelSwitch,
ILogJanitor logJanitor, ILogJanitor logJanitor,
ISettingsPersister settingsPersister, ISettingsPersister settingsPersister,
ISettingsProvider settingsProvider,
IConfigurationLoader<RadarrConfiguration> configLoader, IConfigurationLoader<RadarrConfiguration> configLoader,
Func<IRadarrQualityDefinitionUpdater> qualityUpdaterFactory, Func<IRadarrQualityDefinitionUpdater> qualityUpdaterFactory,
Func<ICustomFormatUpdater> customFormatUpdaterFactory) Func<ICustomFormatUpdater> customFormatUpdaterFactory)
: base(log, loggingLevelSwitch, logJanitor, settingsPersister) : base(log, loggingLevelSwitch, logJanitor, settingsPersister, settingsProvider)
{ {
_log = log; _log = log;
_configLoader = configLoader; _configLoader = configLoader;

@ -25,23 +25,30 @@ public abstract class ServiceCommand : ICommand, IServiceCommand
private readonly LoggingLevelSwitch _loggingLevelSwitch; private readonly LoggingLevelSwitch _loggingLevelSwitch;
private readonly ILogJanitor _logJanitor; private readonly ILogJanitor _logJanitor;
private readonly ISettingsPersister _settingsPersister; private readonly ISettingsPersister _settingsPersister;
private readonly ISettingsProvider _settingsProvider;
protected ServiceCommand( protected ServiceCommand(
ILogger log, ILogger log,
LoggingLevelSwitch loggingLevelSwitch, LoggingLevelSwitch loggingLevelSwitch,
ILogJanitor logJanitor, ILogJanitor logJanitor,
ISettingsPersister settingsPersister) ISettingsPersister settingsPersister,
ISettingsProvider settingsProvider)
{ {
_loggingLevelSwitch = loggingLevelSwitch; _loggingLevelSwitch = loggingLevelSwitch;
_logJanitor = logJanitor; _logJanitor = logJanitor;
_settingsPersister = settingsPersister; _settingsPersister = settingsPersister;
_settingsProvider = settingsProvider;
_log = log; _log = log;
} }
public async ValueTask ExecuteAsync(IConsole console) public async ValueTask ExecuteAsync(IConsole console)
{ {
// Must happen first because everything can use the logger.
SetupLogging(); SetupLogging();
// Has to happen right after logging because stuff below may use settings.
LoadSettings(); LoadSettings();
SetupHttp(); SetupHttp();
try try
@ -122,7 +129,12 @@ public abstract class ServiceCommand : ICommand, IServiceCommand
settings.JsonSerializer = new NewtonsoftJsonSerializer(jsonSettings); settings.JsonSerializer = new NewtonsoftJsonSerializer(jsonSettings);
FlurlLogging.SetupLogging(settings, _log); 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();
}
}); });
} }

@ -28,10 +28,11 @@ public class SonarrCommand : ServiceCommand
LoggingLevelSwitch loggingLevelSwitch, LoggingLevelSwitch loggingLevelSwitch,
ILogJanitor logJanitor, ILogJanitor logJanitor,
ISettingsPersister settingsPersister, ISettingsPersister settingsPersister,
ISettingsProvider settingsProvider,
IConfigurationLoader<SonarrConfiguration> configLoader, IConfigurationLoader<SonarrConfiguration> configLoader,
Func<IReleaseProfileUpdater> profileUpdaterFactory, Func<IReleaseProfileUpdater> profileUpdaterFactory,
Func<ISonarrQualityDefinitionUpdater> qualityUpdaterFactory) Func<ISonarrQualityDefinitionUpdater> qualityUpdaterFactory)
: base(log, loggingLevelSwitch, logJanitor, settingsPersister) : base(log, loggingLevelSwitch, logJanitor, settingsPersister, settingsProvider)
{ {
_log = log; _log = log;
_configLoader = configLoader; _configLoader = configLoader;

Loading…
Cancel
Save