diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index af292c6b23..bd8b68175a 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -111,7 +111,6 @@ namespace OpenSim.Framework.Servers.HttpServer protected uint m_sslport; protected bool m_ssl; private X509Certificate2 m_cert; - protected bool m_firstcaps = true; protected string m_SSLCommonName = ""; protected List m_certNames = new List(); protected List m_certIPs = new List(); @@ -152,11 +151,6 @@ namespace OpenSim.Framework.Servers.HttpServer m_port = port; } - public BaseHttpServer(uint port, bool ssl) : this (port) - { - m_ssl = ssl; - } - private void load_cert(string CPath, string CPass) { try @@ -216,21 +210,24 @@ namespace OpenSim.Framework.Servers.HttpServer if(m_cert.Issuer == m_cert.Subject ) m_log.Warn("Self signed certificate. Clients need to allow this (some viewers debug option NoVerifySSLcert must be set to true"); - - } else m_ssl = false; } - public BaseHttpServer(uint port, bool ssl, string CPath, string CPass) : this (port, ssl) + public BaseHttpServer(uint port, bool ssl, string CPath, string CPass) { - if (m_ssl) + m_port = port; + if (ssl) { load_cert(CPath, CPass); if(m_cert.Issuer == m_cert.Subject ) m_log.Warn("Self signed certificate. Http clients need to allow this"); + m_ssl = true; + m_sslport = port; } + else + m_ssl = false; } static bool MatchDNS (string hostname, string dns) @@ -2038,7 +2035,7 @@ namespace OpenSim.Framework.Servers.HttpServer public void Start() { - Start(true); + Start(true,true); } /// @@ -2048,7 +2045,7 @@ namespace OpenSim.Framework.Servers.HttpServer /// If true then poll responses are performed asynchronsly. /// Option exists to allow regression tests to perform processing synchronously. /// - public void Start(bool performPollResponsesAsync) + public void Start(bool performPollResponsesAsync, bool runPool) { m_log.InfoFormat( "[BASE HTTP SERVER]: Starting {0} server on port {1}", UseSSL ? "HTTPS" : "HTTP", Port); @@ -2086,9 +2083,11 @@ namespace OpenSim.Framework.Servers.HttpServer m_httpListener2.Start(64); // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events - - PollServiceRequestManager = new PollServiceRequestManager(this, performPollResponsesAsync, 2, 25000); - PollServiceRequestManager.Start(); + if(runPool) + { + PollServiceRequestManager = new PollServiceRequestManager(this, performPollResponsesAsync, 2, 25000); + PollServiceRequestManager.Start(); + } HTTPDRunning = true; diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index 57931d449d..e9c284c155 100644 --- a/OpenSim/Framework/Servers/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs @@ -42,6 +42,7 @@ namespace OpenSim.Framework.Servers // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static BaseHttpServer instance = null; + private static BaseHttpServer unsecureinstance = null; private static Dictionary m_Servers = new Dictionary(); /// @@ -93,6 +94,21 @@ namespace OpenSim.Framework.Servers } } + + public static BaseHttpServer ÚnSecureInstance + { + get { return unsecureinstance; } + + set + { + lock (m_Servers) + if (!m_Servers.ContainsValue(value)) + throw new Exception("HTTP server must already have been registered to be set as the main instance"); + + unsecureinstance = value; + } + } + /// /// Get all the registered servers. /// diff --git a/OpenSim/Region/Application/RegionApplicationBase.cs b/OpenSim/Region/Application/RegionApplicationBase.cs index 603f139ecb..77b0138e6b 100644 --- a/OpenSim/Region/Application/RegionApplicationBase.cs +++ b/OpenSim/Region/Application/RegionApplicationBase.cs @@ -69,23 +69,38 @@ namespace OpenSim Initialize(); - m_httpServer - = new BaseHttpServer( - m_httpServerPort, m_networkServersInfo.HttpUsesSSL, - m_networkServersInfo.httpSSLPort, m_networkServersInfo.HttpSSLCN, - m_networkServersInfo.HttpSSLCertPath, m_networkServersInfo.HttpSSLCNCertPass); + uint mainport = m_networkServersInfo.HttpListenerPort; + uint mainSSLport =m_networkServersInfo.httpSSLPort; -/* why this? we only run one - if (m_networkServersInfo.HttpUsesSSL && (m_networkServersInfo.HttpListenerPort == m_networkServersInfo.httpSSLPort)) + if (m_networkServersInfo.HttpUsesSSL && (mainport == mainSSLport)) { 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{0} server on port {1}", - m_networkServersInfo.HttpUsesSSL ? "S" : "", m_httpServerPort); - m_httpServer.Start(); - MainServer.AddHttpServer(m_httpServer); + if(m_networkServersInfo.HttpUsesSSL) + { + m_httpServer = new BaseHttpServer( + mainSSLport, m_networkServersInfo.HttpUsesSSL, + mainSSLport, m_networkServersInfo.HttpSSLCN, + m_networkServersInfo.HttpSSLCertPath, m_networkServersInfo.HttpSSLCNCertPass); + m_httpServer.Start(true,true); + MainServer.AddHttpServer(m_httpServer); + + } + + // unsecure main server + BaseHttpServer server = new BaseHttpServer(mainport); + if(!m_networkServersInfo.HttpUsesSSL) + { + m_httpServer = server; + server.Start(true, true); + } + else + server.Start(false, false); + + MainServer.AddHttpServer(server); + MainServer.ÚnSecureInstance = server; + MainServer.Instance = m_httpServer; // "OOB" Server @@ -93,22 +108,22 @@ namespace OpenSim { if (!m_networkServersInfo.ssl_external) { - BaseHttpServer server = new BaseHttpServer( - m_networkServersInfo.https_port, m_networkServersInfo.ssl_listener, m_networkServersInfo.cert_path, + server = new BaseHttpServer( + m_networkServersInfo.https_port, m_networkServersInfo.ssl_listener, + m_networkServersInfo.cert_path, m_networkServersInfo.cert_pass); - m_log.InfoFormat("[REGION SERVER]: Starting HTTPS server on port {0}", server.Port); + m_log.InfoFormat("[REGION SERVER]: Starting OOB HTTPS server on port {0}", server.SSLPort); + server.Start(false, false); MainServer.AddHttpServer(server); - server.Start(); } else { - BaseHttpServer server = new BaseHttpServer( - m_networkServersInfo.https_port); + server = new BaseHttpServer(m_networkServersInfo.https_port); m_log.InfoFormat("[REGION SERVER]: Starting HTTP server on port {0} for external HTTPS", server.Port); + server.Start(false, false); MainServer.AddHttpServer(server); - server.Start(); } } diff --git a/OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs b/OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs index 50276ae010..9273b20bca 100644 --- a/OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs +++ b/OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs @@ -52,12 +52,12 @@ namespace OpenSim.Region.DataSnapshot m_externalData = externalData; //Register HTTP handler - if (MainServer.Instance.AddHTTPHandler("collector", OnGetSnapshot)) + if (MainServer.ÚnSecureInstance.AddHTTPHandler("collector", OnGetSnapshot)) { m_log.Info("[DATASNAPSHOT]: Set up snapshot service"); } // Register validation callback handler - MainServer.Instance.AddHTTPHandler("validate", OnValidate); + MainServer.ÚnSecureInstance.AddHTTPHandler("validate", OnValidate); }