aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs')
-rw-r--r--OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs42
1 files changed, 35 insertions, 7 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
index d78931a..4c8424d 100644
--- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
+++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
@@ -29,8 +29,10 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Net; 31using System.Net;
32using System.Net.Security;
32using System.Text; 33using System.Text;
33using System.Threading; 34using System.Threading;
35using System.Security.Cryptography.X509Certificates;
34using Nini.Config; 36using Nini.Config;
35using OpenMetaverse; 37using OpenMetaverse;
36using OpenSim.Framework; 38using OpenSim.Framework;
@@ -100,8 +102,24 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
100 102
101 public HttpRequestModule() 103 public HttpRequestModule()
102 { 104 {
105 ServicePointManager.ServerCertificateValidationCallback +=ValidateServerCertificate;
103 } 106 }
104 107
108 public static bool ValidateServerCertificate(
109 object sender,
110 X509Certificate certificate,
111 X509Chain chain,
112 SslPolicyErrors sslPolicyErrors)
113 {
114 HttpWebRequest Request = (HttpWebRequest)sender;
115
116 if (Request.Headers.Get("NoVerifyCert") != null)
117 {
118 return true;
119 }
120
121 return chain.Build(new X509Certificate2(certificate));
122 }
105 #region IHttpRequestModule Members 123 #region IHttpRequestModule Members
106 124
107 public UUID MakeHttpRequest(string url, string parameters, string body) 125 public UUID MakeHttpRequest(string url, string parameters, string body)
@@ -141,8 +159,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
141 break; 159 break;
142 160
143 case (int)HttpRequestConstants.HTTP_VERIFY_CERT: 161 case (int)HttpRequestConstants.HTTP_VERIFY_CERT:
144 162 htc.HttpVerifyCert = (int.Parse(parms[i + 1]) != 0);
145 // TODO implement me
146 break; 163 break;
147 } 164 }
148 } 165 }
@@ -189,7 +206,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
189 * Not sure how important ordering is is here - the next first 206 * Not sure how important ordering is is here - the next first
190 * one completed in the list is returned, based soley on its list 207 * one completed in the list is returned, based soley on its list
191 * position, not the order in which the request was started or 208 * position, not the order in which the request was started or
192 * finsihed. I thought about setting up a queue for this, but 209 * finished. I thought about setting up a queue for this, but
193 * it will need some refactoring and this works 'enough' right now 210 * it will need some refactoring and this works 'enough' right now
194 */ 211 */
195 212
@@ -237,8 +254,8 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
237 254
238 m_scene.RegisterModuleInterface<IHttpRequestModule>(this); 255 m_scene.RegisterModuleInterface<IHttpRequestModule>(this);
239 256
240 m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); 257 m_proxyurl = config.Configs["Startup"].GetString("HttpProxy");
241 m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); 258 m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions");
242 259
243 m_pendingRequests = new Dictionary<UUID, HttpRequestClass>(); 260 m_pendingRequests = new Dictionary<UUID, HttpRequestClass>();
244 } 261 }
@@ -282,7 +299,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
282 public string HttpMethod = "GET"; 299 public string HttpMethod = "GET";
283 public string HttpMIMEType = "text/plain;charset=utf-8"; 300 public string HttpMIMEType = "text/plain;charset=utf-8";
284 public int HttpTimeout; 301 public int HttpTimeout;
285 // public bool HttpVerifyCert = true; // not implemented 302 public bool HttpVerifyCert = true;
286 private Thread httpThread; 303 private Thread httpThread;
287 304
288 // Request info 305 // Request info
@@ -344,6 +361,17 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
344 Request.Method = HttpMethod; 361 Request.Method = HttpMethod;
345 Request.ContentType = HttpMIMEType; 362 Request.ContentType = HttpMIMEType;
346 363
364 if(!HttpVerifyCert)
365 {
366 // We could hijack Connection Group Name to identify
367 // a desired security exception. But at the moment we'll use a dummy header instead.
368// Request.ConnectionGroupName = "NoVerify";
369 Request.Headers.Add("NoVerifyCert", "true");
370 }
371// else
372// {
373// Request.ConnectionGroupName="Verify";
374// }
347 if (proxyurl != null && proxyurl.Length > 0) 375 if (proxyurl != null && proxyurl.Length > 0)
348 { 376 {
349 if (proxyexcepts != null && proxyexcepts.Length > 0) 377 if (proxyexcepts != null && proxyexcepts.Length > 0)
@@ -436,4 +464,4 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
436 } 464 }
437 } 465 }
438 } 466 }
439} 467} \ No newline at end of file