mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-16 14:03:03 +03:00
Create self signed cert if one does not exist
This commit is contained in:
@@ -779,6 +779,13 @@ namespace MediaBrowser.Server.Startup.Common
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ServerConfigurationManager.Configuration.EnableHttps)
|
||||
{
|
||||
NetworkManager.GenerateSelfSignedSslCertificate(
|
||||
ServerConfigurationManager.Configuration.CertificatePath,
|
||||
GetHostnameFromExternalDns(ServerConfigurationManager.Configuration.WanDdns));
|
||||
}
|
||||
|
||||
ServerManager.Start(GetUrlPrefixes(), ServerConfigurationManager.Configuration.CertificatePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -1183,5 +1190,29 @@ namespace MediaBrowser.Server.Startup.Common
|
||||
NativeApp.ConfigureAutoRun(autorun);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This returns localhost in the case of no external dns, and the hostname if the
|
||||
/// dns is prefixed with a valid Uri prefix.
|
||||
/// </summary>
|
||||
/// <param name="externalDns">The external dns prefix to get the hostname of.</param>
|
||||
/// <returns>The hostname in <paramref name="externalDns"/></returns>
|
||||
private static string GetHostnameFromExternalDns(string externalDns)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(externalDns))
|
||||
{
|
||||
return "localhost";
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Uri uri = new Uri(externalDns);
|
||||
return uri.Host;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return externalDns;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user