mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-18 03:19:06 -07:00
commit
090783d41a
@ -257,7 +257,7 @@ namespace Emby.Server.Core
|
|||||||
internal IPowerManagement PowerManagement { get; private set; }
|
internal IPowerManagement PowerManagement { get; private set; }
|
||||||
internal IImageEncoder ImageEncoder { get; private set; }
|
internal IImageEncoder ImageEncoder { get; private set; }
|
||||||
|
|
||||||
private readonly Action<string, string> _certificateGenerator;
|
private readonly Action<string, string, string> _certificateGenerator;
|
||||||
private readonly Func<string> _defaultUserNameFactory;
|
private readonly Func<string> _defaultUserNameFactory;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -274,7 +274,7 @@ namespace Emby.Server.Core
|
|||||||
ISystemEvents systemEvents,
|
ISystemEvents systemEvents,
|
||||||
IMemoryStreamFactory memoryStreamFactory,
|
IMemoryStreamFactory memoryStreamFactory,
|
||||||
INetworkManager networkManager,
|
INetworkManager networkManager,
|
||||||
Action<string, string> certificateGenerator,
|
Action<string, string, string> certificateGenerator,
|
||||||
Func<string> defaultUsernameFactory)
|
Func<string> defaultUsernameFactory)
|
||||||
: base(applicationPaths,
|
: base(applicationPaths,
|
||||||
logManager,
|
logManager,
|
||||||
@ -609,8 +609,8 @@ namespace Emby.Server.Core
|
|||||||
|
|
||||||
RegisterSingleInstance<ISearchEngine>(() => new SearchEngine(LogManager, LibraryManager, UserManager));
|
RegisterSingleInstance<ISearchEngine>(() => new SearchEngine(LogManager, LibraryManager, UserManager));
|
||||||
|
|
||||||
CertificatePath = GetCertificatePath(true);
|
CertificateInfo = GetCertificateInfo(true);
|
||||||
Certificate = GetCertificate(CertificatePath);
|
Certificate = GetCertificate(CertificateInfo);
|
||||||
|
|
||||||
HttpServer = HttpServerFactory.CreateServer(this, LogManager, ServerConfigurationManager, NetworkManager, MemoryStreamFactory, "Emby", "web/index.html", textEncoding, SocketFactory, CryptographyProvider, JsonSerializer, XmlSerializer, EnvironmentInfo, Certificate, FileSystemManager, SupportsDualModeSockets);
|
HttpServer = HttpServerFactory.CreateServer(this, LogManager, ServerConfigurationManager, NetworkManager, MemoryStreamFactory, "Emby", "web/index.html", textEncoding, SocketFactory, CryptographyProvider, JsonSerializer, XmlSerializer, EnvironmentInfo, Certificate, FileSystemManager, SupportsDualModeSockets);
|
||||||
HttpServer.GlobalResponse = LocalizationManager.GetLocalizedString("StartupEmbyServerIsLoading");
|
HttpServer.GlobalResponse = LocalizationManager.GetLocalizedString("StartupEmbyServerIsLoading");
|
||||||
@ -745,8 +745,10 @@ namespace Emby.Server.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICertificate GetCertificate(string certificateLocation)
|
private ICertificate GetCertificate(CertificateInfo info)
|
||||||
{
|
{
|
||||||
|
var certificateLocation = info == null ? null : info.Path;
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(certificateLocation))
|
if (string.IsNullOrWhiteSpace(certificateLocation))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
@ -759,7 +761,7 @@ namespace Emby.Server.Core
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
X509Certificate2 localCert = new X509Certificate2(certificateLocation);
|
X509Certificate2 localCert = new X509Certificate2(certificateLocation, info.Password);
|
||||||
//localCert.PrivateKey = PrivateKey.CreateFromFile(pvk_file).RSA;
|
//localCert.PrivateKey = PrivateKey.CreateFromFile(pvk_file).RSA;
|
||||||
if (!localCert.HasPrivateKey)
|
if (!localCert.HasPrivateKey)
|
||||||
{
|
{
|
||||||
@ -1064,7 +1066,7 @@ namespace Emby.Server.Core
|
|||||||
SyncManager.AddParts(GetExports<ISyncProvider>());
|
SyncManager.AddParts(GetExports<ISyncProvider>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private string CertificatePath { get; set; }
|
private CertificateInfo CertificateInfo { get; set; }
|
||||||
private ICertificate Certificate { get; set; }
|
private ICertificate Certificate { get; set; }
|
||||||
|
|
||||||
private IEnumerable<string> GetUrlPrefixes()
|
private IEnumerable<string> GetUrlPrefixes()
|
||||||
@ -1080,7 +1082,7 @@ namespace Emby.Server.Core
|
|||||||
"http://"+i+":" + HttpPort + "/"
|
"http://"+i+":" + HttpPort + "/"
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(CertificatePath))
|
if (CertificateInfo != null)
|
||||||
{
|
{
|
||||||
prefixes.Add("https://" + i + ":" + HttpsPort + "/");
|
prefixes.Add("https://" + i + ":" + HttpsPort + "/");
|
||||||
}
|
}
|
||||||
@ -1123,17 +1125,21 @@ namespace Emby.Server.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetCertificatePath(bool generateCertificate)
|
private CertificateInfo GetCertificateInfo(bool generateCertificate)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrWhiteSpace(ServerConfigurationManager.Configuration.CertificatePath))
|
if (!string.IsNullOrWhiteSpace(ServerConfigurationManager.Configuration.CertificatePath))
|
||||||
{
|
{
|
||||||
// Custom cert
|
// Custom cert
|
||||||
return ServerConfigurationManager.Configuration.CertificatePath;
|
return new CertificateInfo
|
||||||
|
{
|
||||||
|
Path = ServerConfigurationManager.Configuration.CertificatePath
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate self-signed cert
|
// Generate self-signed cert
|
||||||
var certHost = GetHostnameFromExternalDns(ServerConfigurationManager.Configuration.WanDdns);
|
var certHost = GetHostnameFromExternalDns(ServerConfigurationManager.Configuration.WanDdns);
|
||||||
var certPath = Path.Combine(ServerConfigurationManager.ApplicationPaths.ProgramDataPath, "ssl", "cert_" + (certHost + "1").GetMD5().ToString("N") + ".pfx");
|
var certPath = Path.Combine(ServerConfigurationManager.ApplicationPaths.ProgramDataPath, "ssl", "cert_" + (certHost + "2").GetMD5().ToString("N") + ".pfx");
|
||||||
|
var password = "embycert";
|
||||||
|
|
||||||
if (generateCertificate)
|
if (generateCertificate)
|
||||||
{
|
{
|
||||||
@ -1143,7 +1149,7 @@ namespace Emby.Server.Core
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_certificateGenerator(certPath, certHost);
|
_certificateGenerator(certPath, certHost, password);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -1153,7 +1159,11 @@ namespace Emby.Server.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return certPath;
|
return new CertificateInfo
|
||||||
|
{
|
||||||
|
Path = certPath,
|
||||||
|
Password = password
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1189,7 +1199,11 @@ namespace Emby.Server.Core
|
|||||||
requiresRestart = true;
|
requiresRestart = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.Equals(CertificatePath, GetCertificatePath(false), StringComparison.OrdinalIgnoreCase))
|
var currentCertPath = CertificateInfo == null ? null : CertificateInfo.Path;
|
||||||
|
var newCertInfo = GetCertificateInfo(false);
|
||||||
|
var newCertPath = newCertInfo == null ? null : newCertInfo.Path;
|
||||||
|
|
||||||
|
if (!string.Equals(currentCertPath, newCertPath, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
requiresRestart = true;
|
requiresRestart = true;
|
||||||
}
|
}
|
||||||
@ -1779,6 +1793,11 @@ namespace Emby.Server.Core
|
|||||||
{
|
{
|
||||||
Container.Register(typeInterface, typeImplementation);
|
Container.Register(typeInterface, typeImplementation);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class CertificateInfo
|
||||||
|
{
|
||||||
|
public string Path { get; set; }
|
||||||
|
public string Password { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,10 @@ namespace Emby.Server.Implementations.Library
|
|||||||
ExcludeItemTypes = excludeItemTypes.ToArray(),
|
ExcludeItemTypes = excludeItemTypes.ToArray(),
|
||||||
IncludeItemTypes = includeItemTypes.ToArray(),
|
IncludeItemTypes = includeItemTypes.ToArray(),
|
||||||
Limit = query.Limit,
|
Limit = query.Limit,
|
||||||
IncludeItemsByName = true
|
IncludeItemsByName = string.IsNullOrWhiteSpace(query.ParentId),
|
||||||
|
ParentId = string.IsNullOrWhiteSpace(query.ParentId) ? (Guid?)null : new Guid(query.ParentId),
|
||||||
|
SortBy = new[] { ItemSortBy.SortName },
|
||||||
|
Recursive = true
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add search hints based on item name
|
// Add search hints based on item name
|
||||||
|
@ -66,6 +66,8 @@ namespace MediaBrowser.Api
|
|||||||
[ApiMember(Name = "IncludeItemTypes", Description = "Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
[ApiMember(Name = "IncludeItemTypes", Description = "Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||||
public string IncludeItemTypes { get; set; }
|
public string IncludeItemTypes { get; set; }
|
||||||
|
|
||||||
|
public string ParentId { get; set; }
|
||||||
|
|
||||||
public GetSearchHints()
|
public GetSearchHints()
|
||||||
{
|
{
|
||||||
IncludeArtists = true;
|
IncludeArtists = true;
|
||||||
@ -135,7 +137,8 @@ namespace MediaBrowser.Api
|
|||||||
IncludeStudios = request.IncludeStudios,
|
IncludeStudios = request.IncludeStudios,
|
||||||
StartIndex = request.StartIndex,
|
StartIndex = request.StartIndex,
|
||||||
UserId = request.UserId,
|
UserId = request.UserId,
|
||||||
IncludeItemTypes = (request.IncludeItemTypes ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToArray()
|
IncludeItemTypes = (request.IncludeItemTypes ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToArray(),
|
||||||
|
ParentId = request.ParentId
|
||||||
|
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ namespace MediaBrowser.Model.Search
|
|||||||
public bool IncludeArtists { get; set; }
|
public bool IncludeArtists { get; set; }
|
||||||
|
|
||||||
public string[] IncludeItemTypes { get; set; }
|
public string[] IncludeItemTypes { get; set; }
|
||||||
|
public string ParentId { get; set; }
|
||||||
|
|
||||||
public SearchQuery()
|
public SearchQuery()
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,7 @@ namespace MediaBrowser.Server.Mac
|
|||||||
{
|
{
|
||||||
public class MacAppHost : ApplicationHost
|
public class MacAppHost : ApplicationHost
|
||||||
{
|
{
|
||||||
public MacAppHost(ServerApplicationPaths applicationPaths, ILogManager logManager, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, string releaseAssetFilename, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, IMemoryStreamFactory memoryStreamFactory, MediaBrowser.Common.Net.INetworkManager networkManager, Action<string, string> certificateGenerator, Func<string> defaultUsernameFactory) : base(applicationPaths, logManager, options, fileSystem, powerManagement, releaseAssetFilename, environmentInfo, imageEncoder, systemEvents, memoryStreamFactory, networkManager, certificateGenerator, defaultUsernameFactory)
|
public MacAppHost(ServerApplicationPaths applicationPaths, ILogManager logManager, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, string releaseAssetFilename, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, IMemoryStreamFactory memoryStreamFactory, MediaBrowser.Common.Net.INetworkManager networkManager, Action<string, string, string> certificateGenerator, Func<string> defaultUsernameFactory) : base(applicationPaths, logManager, options, fileSystem, powerManagement, releaseAssetFilename, environmentInfo, imageEncoder, systemEvents, memoryStreamFactory, networkManager, certificateGenerator, defaultUsernameFactory)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ namespace MediaBrowser.Server.Mono
|
|||||||
{
|
{
|
||||||
public class MonoAppHost : ApplicationHost
|
public class MonoAppHost : ApplicationHost
|
||||||
{
|
{
|
||||||
public MonoAppHost(ServerApplicationPaths applicationPaths, ILogManager logManager, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, string releaseAssetFilename, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, IMemoryStreamFactory memoryStreamFactory, MediaBrowser.Common.Net.INetworkManager networkManager, Action<string, string> certificateGenerator, Func<string> defaultUsernameFactory) : base(applicationPaths, logManager, options, fileSystem, powerManagement, releaseAssetFilename, environmentInfo, imageEncoder, systemEvents, memoryStreamFactory, networkManager, certificateGenerator, defaultUsernameFactory)
|
public MonoAppHost(ServerApplicationPaths applicationPaths, ILogManager logManager, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, string releaseAssetFilename, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, IMemoryStreamFactory memoryStreamFactory, MediaBrowser.Common.Net.INetworkManager networkManager, Action<string, string, string> certificateGenerator, Func<string> defaultUsernameFactory) : base(applicationPaths, logManager, options, fileSystem, powerManagement, releaseAssetFilename, environmentInfo, imageEncoder, systemEvents, memoryStreamFactory, networkManager, certificateGenerator, defaultUsernameFactory)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,9 +159,9 @@ namespace MediaBrowser.Server.Mono
|
|||||||
Task.WaitAll(task);
|
Task.WaitAll(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void GenerateCertificate(string certPath, string certHost)
|
private static void GenerateCertificate(string certPath, string certHost, string certPassword)
|
||||||
{
|
{
|
||||||
CertificateGenerator.CreateSelfSignCertificatePfx(certPath, certHost, _logger);
|
CertificateGenerator.CreateSelfSignCertificatePfx(certPath, certHost, certPassword, _logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MonoEnvironmentInfo GetEnvironmentInfo()
|
private static MonoEnvironmentInfo GetEnvironmentInfo()
|
||||||
|
@ -12,6 +12,7 @@ namespace Emby.Common.Implementations.Security
|
|||||||
public static void CreateSelfSignCertificatePfx(
|
public static void CreateSelfSignCertificatePfx(
|
||||||
string fileName,
|
string fileName,
|
||||||
string hostname,
|
string hostname,
|
||||||
|
string password,
|
||||||
ILogger logger)
|
ILogger logger)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(fileName))
|
if (string.IsNullOrWhiteSpace(fileName))
|
||||||
@ -43,7 +44,7 @@ namespace Emby.Common.Implementations.Security
|
|||||||
cb.NotAfter = notAfter;
|
cb.NotAfter = notAfter;
|
||||||
cb.SubjectName = subject;
|
cb.SubjectName = subject;
|
||||||
cb.SubjectPublicKey = subjectKey;
|
cb.SubjectPublicKey = subjectKey;
|
||||||
|
|
||||||
// signature
|
// signature
|
||||||
cb.Hash = "SHA256";
|
cb.Hash = "SHA256";
|
||||||
byte[] rawcert = cb.Sign(issuerKey);
|
byte[] rawcert = cb.Sign(issuerKey);
|
||||||
@ -59,6 +60,7 @@ namespace Emby.Common.Implementations.Security
|
|||||||
attributes.Add(PKCS9.localKeyId, list);
|
attributes.Add(PKCS9.localKeyId, list);
|
||||||
|
|
||||||
p12.AddCertificate(new X509Certificate(rawcert), attributes);
|
p12.AddCertificate(new X509Certificate(rawcert), attributes);
|
||||||
|
p12.Password = password;
|
||||||
|
|
||||||
p12.AddPkcs8ShroudedKeyBag(subjectKey, attributes);
|
p12.AddPkcs8ShroudedKeyBag(subjectKey, attributes);
|
||||||
p12.SaveToFile(fileName);
|
p12.SaveToFile(fileName);
|
||||||
|
@ -391,9 +391,9 @@ namespace MediaBrowser.ServerApplication
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void GenerateCertificate(string certPath, string certHost)
|
private static void GenerateCertificate(string certPath, string certHost, string certPassword)
|
||||||
{
|
{
|
||||||
CertificateGenerator.CreateSelfSignCertificatePfx(certPath, certHost, _logger);
|
CertificateGenerator.CreateSelfSignCertificatePfx(certPath, certHost, certPassword, _logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ServerNotifyIcon _serverNotifyIcon;
|
private static ServerNotifyIcon _serverNotifyIcon;
|
||||||
|
@ -25,7 +25,7 @@ namespace MediaBrowser.ServerApplication
|
|||||||
{
|
{
|
||||||
public class WindowsAppHost : ApplicationHost
|
public class WindowsAppHost : ApplicationHost
|
||||||
{
|
{
|
||||||
public WindowsAppHost(ServerApplicationPaths applicationPaths, ILogManager logManager, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, string releaseAssetFilename, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, IMemoryStreamFactory memoryStreamFactory, MediaBrowser.Common.Net.INetworkManager networkManager, Action<string, string> certificateGenerator, Func<string> defaultUsernameFactory)
|
public WindowsAppHost(ServerApplicationPaths applicationPaths, ILogManager logManager, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, string releaseAssetFilename, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, IMemoryStreamFactory memoryStreamFactory, MediaBrowser.Common.Net.INetworkManager networkManager, Action<string, string, string> certificateGenerator, Func<string> defaultUsernameFactory)
|
||||||
: base(applicationPaths, logManager, options, fileSystem, powerManagement, releaseAssetFilename, environmentInfo, imageEncoder, systemEvents, memoryStreamFactory, networkManager, certificateGenerator, defaultUsernameFactory)
|
: base(applicationPaths, logManager, options, fileSystem, powerManagement, releaseAssetFilename, environmentInfo, imageEncoder, systemEvents, memoryStreamFactory, networkManager, certificateGenerator, defaultUsernameFactory)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
[assembly: AssemblyVersion("3.2.13.9")]
|
[assembly: AssemblyVersion("3.2.13.10")]
|
||||||
|
Loading…
Reference in New Issue
Block a user