diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index d78931a..a37c781 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs | |||
@@ -29,8 +29,10 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.IO; | 30 | using System.IO; |
31 | using System.Net; | 31 | using System.Net; |
32 | using System.Net.Security; | ||
32 | using System.Text; | 33 | using System.Text; |
33 | using System.Threading; | 34 | using System.Threading; |
35 | using System.Security.Cryptography.X509Certificates; | ||
34 | using Nini.Config; | 36 | using Nini.Config; |
35 | using OpenMetaverse; | 37 | using OpenMetaverse; |
36 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
@@ -84,6 +86,7 @@ using OpenSim.Region.Framework.Scenes; | |||
84 | 86 | ||
85 | namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | 87 | namespace OpenSim.Region.CoreModules.Scripting.HttpRequest |
86 | { | 88 | { |
89 | |||
87 | public class HttpRequestModule : IRegionModule, IHttpRequestModule | 90 | public class HttpRequestModule : IRegionModule, IHttpRequestModule |
88 | { | 91 | { |
89 | private object HttpListLock = new object(); | 92 | private object HttpListLock = new object(); |
@@ -100,8 +103,23 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
100 | 103 | ||
101 | public HttpRequestModule() | 104 | public HttpRequestModule() |
102 | { | 105 | { |
106 | ServicePointManager.ServerCertificateValidationCallback +=ValidateServerCertificate; | ||
103 | } | 107 | } |
104 | 108 | ||
109 | public static bool ValidateServerCertificate( | ||
110 | object sender, | ||
111 | X509Certificate certificate, | ||
112 | X509Chain chain, | ||
113 | SslPolicyErrors sslPolicyErrors) | ||
114 | { | ||
115 | HttpWebRequest Request = (HttpWebRequest)sender; | ||
116 | |||
117 | if(Request.Headers.Get("NoVerifyCert") != null) | ||
118 | { | ||
119 | return true; | ||
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 | } |
@@ -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; // not implemented |
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 | // Connection Group Name is probably not used so we hijack it to identify | ||
367 | // a desired security exception | ||
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) |