mirror of
https://github.com/Radarr/Radarr
synced 2025-02-26 16:13:19 +00:00
Fixed: Changing the SSL cert will re-register with the new cert (when running as admin)
This commit is contained in:
parent
007f96677c
commit
b89d9c22b9
1 changed files with 27 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
|
|
||||||
|
@ -13,6 +14,7 @@ public interface ISslAdapter
|
||||||
public class SslAdapter : ISslAdapter
|
public class SslAdapter : ISslAdapter
|
||||||
{
|
{
|
||||||
private const string APP_ID = "C2172AF4-F9A6-4D91-BAEE-C2E4EE680613";
|
private const string APP_ID = "C2172AF4-F9A6-4D91-BAEE-C2E4EE680613";
|
||||||
|
private static readonly Regex CertificateHashRegex = new Regex(@"^\s+(?:Certificate Hash\s+:\s+)(?<hash>\w+)", RegexOptions.Compiled);
|
||||||
|
|
||||||
private readonly INetshProvider _netshProvider;
|
private readonly INetshProvider _netshProvider;
|
||||||
private readonly IConfigFileProvider _configFileProvider;
|
private readonly IConfigFileProvider _configFileProvider;
|
||||||
|
@ -54,7 +56,32 @@ private bool IsRegistered()
|
||||||
|
|
||||||
if (output == null || !output.Standard.Any()) return false;
|
if (output == null || !output.Standard.Any()) return false;
|
||||||
|
|
||||||
|
var hashLine = output.Standard.SingleOrDefault(line => CertificateHashRegex.IsMatch(line));
|
||||||
|
|
||||||
|
if (hashLine != null)
|
||||||
|
{
|
||||||
|
var match = CertificateHashRegex.Match(hashLine);
|
||||||
|
|
||||||
|
if (match.Success)
|
||||||
|
{
|
||||||
|
if (match.Groups["hash"].Value != _configFileProvider.SslCertHash)
|
||||||
|
{
|
||||||
|
Unregister();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return output.Standard.Any(line => line.Contains(ipPort));
|
return output.Standard.Any(line => line.Contains(ipPort));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Unregister()
|
||||||
|
{
|
||||||
|
var ipPort = "0.0.0.0:" + _configFileProvider.SslPort;
|
||||||
|
var arguments = String.Format("http delete sslcert ipport={0}", ipPort);
|
||||||
|
|
||||||
|
_netshProvider.Run(arguments);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue