From b51739e23ecc071a107755c7613ff274f65c3a64 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 6 Oct 2016 21:35:11 +0100 Subject: recover regions main http server ssl suport. Using a PKCS12 cert file, and not certs store for now. Option http_listener_cn, cert CN need to the same as external IP. Self sign certs do seem to work, but the viewers option NoVerifySLLCert needs to be set true. CA check is not done but they do check the IP --- OpenSim/Framework/NetworkServersInfo.cs | 4 ++++ .../Framework/Servers/HttpServer/BaseHttpServer.cs | 10 ++++++++- OpenSim/Region/Application/OpenSimBase.cs | 26 ++++++++++++++++++++-- .../Region/Application/RegionApplicationBase.cs | 14 +++++++----- .../Caps/EventQueue/Tests/EventQueueTests.cs | 2 +- .../ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs | 2 +- 6 files changed, 48 insertions(+), 10 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/NetworkServersInfo.cs b/OpenSim/Framework/NetworkServersInfo.cs index dfe9695..d79eb0d 100644 --- a/OpenSim/Framework/NetworkServersInfo.cs +++ b/OpenSim/Framework/NetworkServersInfo.cs @@ -37,6 +37,8 @@ namespace OpenSim.Framework public bool isSandbox; public bool HttpUsesSSL = false; public string HttpSSLCN = ""; + public string HttpSSLCertPath = ""; + public string HttpSSLCNCertPass = ""; public uint httpSSLPort = 9001; // "Out of band" managemnt https @@ -62,6 +64,8 @@ namespace OpenSim.Framework (uint)config.Configs["Network"].GetInt("http_listener_sslport", ((int)ConfigSettings.DefaultRegionHttpPort+1)); HttpUsesSSL = config.Configs["Network"].GetBoolean("http_listener_ssl", false); HttpSSLCN = config.Configs["Network"].GetString("http_listener_cn", "localhost"); + HttpSSLCertPath = config.Configs["Network"].GetString("http_listener_cert_path", HttpSSLCertPath); + HttpSSLCNCertPass = config.Configs["Network"].GetString("http_listener_cert_pass", HttpSSLCNCertPass); // "Out of band management https" ssl_listener = config.Configs["Network"].GetBoolean("https_listener",false); diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index c078a73..29a8d3f 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -153,11 +153,19 @@ namespace OpenSim.Framework.Servers.HttpServer m_ssl = ssl; } - public BaseHttpServer(uint port, bool ssl, uint sslport, string CN) : this (port, ssl) + public BaseHttpServer(uint port, bool ssl, uint sslport, string CN, string CPath, string CPass) : this (port, ssl) { if (m_ssl) { + if(string.IsNullOrEmpty(CPass)) + throw new Exception("invalid main http server cert path"); + m_sslport = sslport; + m_cert = new X509Certificate2(CPath, CPass); + m_SSLCommonName = m_cert.GetNameInfo(X509NameType.SimpleName,false); + if(CN != m_SSLCommonName) + throw new Exception("main http server CN does not match cert CN"); + } } diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 52ded3d..62abf8e 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -351,7 +351,18 @@ namespace OpenSim if (startupConfig == null || startupConfig.GetBoolean("JobEngineEnabled", true)) WorkManager.JobEngine.Start(); - m_httpServerPort = m_networkServersInfo.HttpListenerPort; + + if(m_networkServersInfo.HttpUsesSSL) + { + m_httpServerSSL = true; + m_httpServerPort = m_networkServersInfo.httpSSLPort; + } + else + { + m_httpServerSSL = false; + m_httpServerPort = m_networkServersInfo.HttpListenerPort; + } + SceneManager.OnRestartSim += HandleRestartRegion; // Only enable the watchdogs when all regions are ready. Otherwise we get false positives when cpu is @@ -404,7 +415,18 @@ namespace OpenSim // set initial ServerURI regionInfo.HttpPort = m_httpServerPort; - regionInfo.ServerURI = "http://" + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort.ToString() + "/"; + if(m_httpServerSSL) + { + if(m_networkServersInfo.HttpSSLCN != regionInfo.ExternalHostName) + throw new Exception("main http cert CN doesn't match region External IP"); + + regionInfo.ServerURI = "https://" + regionInfo.ExternalHostName + + ":" + regionInfo.HttpPort.ToString() + "/"; + } + else + regionInfo.ServerURI = "http://" + regionInfo.ExternalHostName + + ":" + regionInfo.HttpPort.ToString() + "/"; + regionInfo.osSecret = m_osSecret; diff --git a/OpenSim/Region/Application/RegionApplicationBase.cs b/OpenSim/Region/Application/RegionApplicationBase.cs index ba92fd6..603f139 100644 --- a/OpenSim/Region/Application/RegionApplicationBase.cs +++ b/OpenSim/Region/Application/RegionApplicationBase.cs @@ -50,6 +50,7 @@ namespace OpenSim protected Dictionary m_clientCircuits = new Dictionary(); protected NetworkServersInfo m_networkServersInfo; protected uint m_httpServerPort; + protected bool m_httpServerSSL; protected ISimulationDataService m_simulationDataService; protected IEstateDataService m_estateDataService; @@ -70,15 +71,18 @@ namespace OpenSim m_httpServer = new BaseHttpServer( - m_httpServerPort, m_networkServersInfo.HttpUsesSSL, m_networkServersInfo.httpSSLPort, - m_networkServersInfo.HttpSSLCN); - + m_httpServerPort, m_networkServersInfo.HttpUsesSSL, + m_networkServersInfo.httpSSLPort, m_networkServersInfo.HttpSSLCN, + m_networkServersInfo.HttpSSLCertPath, m_networkServersInfo.HttpSSLCNCertPass); + +/* why this? we only run one if (m_networkServersInfo.HttpUsesSSL && (m_networkServersInfo.HttpListenerPort == m_networkServersInfo.httpSSLPort)) { m_log.Error("[REGION SERVER]: HTTP Server config failed. HTTP Server and HTTPS server must be on different ports"); } - - m_log.InfoFormat("[REGION SERVER]: Starting HTTP server on port {0}", m_httpServerPort); +*/ + m_log.InfoFormat("[REGION SERVER]: Starting HTTP{0} server on port {1}", + m_networkServersInfo.HttpUsesSSL ? "S" : "", m_httpServerPort); m_httpServer.Start(); MainServer.AddHttpServer(m_httpServer); diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs index 5eb4452..507d9b8 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs @@ -65,7 +65,7 @@ namespace OpenSim.Region.ClientStack.Linden.Tests // variables and the VM is not restarted between tests. MainServer.RemoveHttpServer(port); - BaseHttpServer server = new BaseHttpServer(port, false, sslPort, ""); + BaseHttpServer server = new BaseHttpServer(port, false, sslPort, "","",""); MainServer.AddHttpServer(server); MainServer.Instance = server; diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs index 30dc4cd..1453204 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs @@ -87,7 +87,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests uint port = 9999; MainServer.RemoveHttpServer(port); - BaseHttpServer server = new BaseHttpServer(port, false, 0, ""); + BaseHttpServer server = new BaseHttpServer(port, false, 0, "", "", ""); MainServer.AddHttpServer(server); MainServer.Instance = server; -- cgit v1.1