fix restart notification for cert config change

pull/702/head
Luke Pulverenti 10 years ago
parent be6418a19e
commit bdb9cd77bc

@ -779,6 +779,22 @@ namespace MediaBrowser.Server.Startup.Common
/// Starts the server.
/// </summary>
private void StartServer()
{
CertificatePath = GetCertificatePath(true);
try
{
ServerManager.Start(GetUrlPrefixes(), CertificatePath);
}
catch (Exception ex)
{
Logger.ErrorException("Error starting http server", ex);
throw;
}
}
private string GetCertificatePath(bool generateCertificate)
{
if (string.IsNullOrWhiteSpace(ServerConfigurationManager.Configuration.CertificatePath))
{
@ -786,37 +802,29 @@ namespace MediaBrowser.Server.Startup.Common
var certHost = GetHostnameFromExternalDns(ServerConfigurationManager.Configuration.WanDdns);
var certPath = Path.Combine(ServerConfigurationManager.ApplicationPaths.ProgramDataPath, "ssl", "cert_" + certHost.GetMD5().ToString("N") + ".pfx");
if (!File.Exists(certPath))
if (generateCertificate)
{
Directory.CreateDirectory(Path.GetDirectoryName(certPath));
try
{
NetworkManager.GenerateSelfSignedSslCertificate(certPath, certHost);
CertificatePath = certHost;
}
catch (Exception ex)
if (!File.Exists(certPath))
{
Logger.ErrorException("Error creating ssl cert", ex);
Directory.CreateDirectory(Path.GetDirectoryName(certPath));
try
{
NetworkManager.GenerateSelfSignedSslCertificate(certPath, certHost);
}
catch (Exception ex)
{
Logger.ErrorException("Error creating ssl cert", ex);
return null;
}
}
}
}
else
{
// Custom cert
CertificatePath = ServerConfigurationManager.Configuration.CertificatePath;
}
try
{
ServerManager.Start(GetUrlPrefixes(), CertificatePath);
return certPath;
}
catch (Exception ex)
{
Logger.ErrorException("Error starting http server", ex);
throw;
}
// Custom cert
return ServerConfigurationManager.Configuration.CertificatePath;
}
/// <summary>
@ -849,7 +857,7 @@ namespace MediaBrowser.Server.Startup.Common
requiresRestart = true;
}
if (!string.Equals(CertificatePath, ServerConfigurationManager.Configuration.CertificatePath, StringComparison.OrdinalIgnoreCase))
if (!string.Equals(CertificatePath, GetCertificatePath(false), StringComparison.OrdinalIgnoreCase))
{
requiresRestart = true;
}

Loading…
Cancel
Save