From 8ca793875318efc8db3339b25bf7fa5ddeeac218 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sun, 1 May 2011 14:44:09 -0400 Subject: Adding ssl support Adding ssl support for "Out of Band" applications such as the remote admin module or Robust services --- OpenSim/Framework/MainServer.cs | 5 +++++ OpenSim/Framework/NetworkServersInfo.cs | 15 +++++++++++++++ OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 14 ++++++++++++++ 3 files changed, 34 insertions(+) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/MainServer.cs b/OpenSim/Framework/MainServer.cs index 0515b16..a3e0a26 100644 --- a/OpenSim/Framework/MainServer.cs +++ b/OpenSim/Framework/MainServer.cs @@ -52,6 +52,11 @@ namespace OpenSim.Framework return GetHttpServer(port,null); } + public static void AddHttpServer(BaseHttpServer server) + { + m_Servers.Add(server.Port, server); + } + public static IHttpServer GetHttpServer(uint port, IPAddress ipaddr) { if (port == 0) diff --git a/OpenSim/Framework/NetworkServersInfo.cs b/OpenSim/Framework/NetworkServersInfo.cs index b25f8b9..5bb4111 100644 --- a/OpenSim/Framework/NetworkServersInfo.cs +++ b/OpenSim/Framework/NetworkServersInfo.cs @@ -49,6 +49,12 @@ namespace OpenSim.Framework public string HttpSSLCN = ""; public uint httpSSLPort = 9001; + // "Out of band" managemnt https + public bool ssl_listener = false; + public uint https_port = 0; + public string cert_path = String.Empty; + public string cert_pass = String.Empty; + public string MessagingURL = String.Empty; public NetworkServersInfo() @@ -86,6 +92,15 @@ namespace OpenSim.Framework secureInventoryServer = config.Configs["Network"].GetBoolean("secure_inventory_server", true); MessagingURL = config.Configs["Network"].GetString("messaging_server_url", string.Empty); + + // "Out of band management https" + ssl_listener = config.Configs["Network"].GetBoolean("https_listener",false); + if( ssl_listener) + { + cert_path = config.Configs["Network"].GetString("cert_path",String.Empty); + cert_pass = config.Configs["Network"].GetString("cert_pass",String.Empty); + https_port = (uint)config.Configs["Network"].GetInt("https_port", 0); + } } } } diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index ba89e21..598e5d1 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -32,6 +32,7 @@ using System.Collections.Specialized; using System.IO; using System.Net; using System.Net.Sockets; +using System.Security.Cryptography.X509Certificates; using System.Reflection; using System.Globalization; using System.Text; @@ -72,6 +73,7 @@ namespace OpenSim.Framework.Servers.HttpServer protected uint m_port; protected uint m_sslport; protected bool m_ssl; + private X509Certificate2 m_cert; protected bool m_firstcaps = true; protected string m_SSLCommonName = ""; @@ -123,6 +125,14 @@ namespace OpenSim.Framework.Servers.HttpServer } } + public BaseHttpServer(uint port, bool ssl, string CPath, string CPass) : this (port, ssl) + { + if (m_ssl) + { + m_cert = new X509Certificate2(CPath, CPass); + } + } + /// /// Add a stream handler to the http server. If the handler already exists, then nothing happens. /// @@ -1683,6 +1693,7 @@ namespace OpenSim.Framework.Servers.HttpServer try { //m_httpListener = new HttpListener(); + NotSocketErrors = 0; if (!m_ssl) { @@ -1702,6 +1713,9 @@ namespace OpenSim.Framework.Servers.HttpServer { //m_httpListener.Prefixes.Add("https://+:" + (m_sslport) + "/"); //m_httpListener.Prefixes.Add("http://+:" + m_port + "/"); + m_httpListener2 = CoolHTTPListener.Create(IPAddress.Any, (int)m_port, m_cert); + m_httpListener2.ExceptionThrown += httpServerException; + m_httpListener2.LogWriter = httpserverlog; } m_httpListener2.RequestReceived += OnRequest; -- cgit v1.1