mirror of
https://github.com/Radarr/Radarr
synced 2026-05-07 13:21:20 +02:00
update http certificate validator to match server startup behavior
This commit is contained in:
parent
15f83cf005
commit
29e9d2992e
1 changed files with 17 additions and 3 deletions
|
|
@ -3,6 +3,7 @@
|
|||
using FluentValidation;
|
||||
using FluentValidation.Validators;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Instrumentation;
|
||||
|
||||
namespace Radarr.Api.V3.Config
|
||||
|
|
@ -33,11 +34,11 @@ protected override bool IsValid(PropertyValidatorContext context)
|
|||
return true;
|
||||
}
|
||||
|
||||
var certificateCollection = new X509Certificate2Collection();
|
||||
|
||||
try
|
||||
{
|
||||
new X509Certificate2(resource.SslCertPath, resource.SslCertPassword, X509KeyStorageFlags.DefaultKeySet);
|
||||
|
||||
return true;
|
||||
certificateCollection.Import(resource.SslCertPath, resource.SslCertPassword, X509KeyStorageFlags.DefaultKeySet);
|
||||
}
|
||||
catch (CryptographicException ex)
|
||||
{
|
||||
|
|
@ -47,6 +48,19 @@ protected override bool IsValid(PropertyValidatorContext context)
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (certificateCollection.None(c => c.HasPrivateKey))
|
||||
{
|
||||
var message = $"The SSL certificate file {resource.SslCertPath} does not contain a certificate with an associated private key";
|
||||
|
||||
Logger.Debug($"{message}");
|
||||
|
||||
context.MessageFormatter.AppendArgument("message", message);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue