Allow SmtpClients and other SSL users to work with our cert handler installed
parent
982f3d58a9
commit
72247bdaef
|
@ -29,6 +29,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Net.Mail;
|
||||||
using System.Net.Security;
|
using System.Net.Security;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
@ -110,22 +111,37 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
|
||||||
X509Certificate certificate,
|
X509Certificate certificate,
|
||||||
X509Chain chain,
|
X509Chain chain,
|
||||||
SslPolicyErrors sslPolicyErrors)
|
SslPolicyErrors sslPolicyErrors)
|
||||||
|
{
|
||||||
|
// If this is a web request we need to check the headers first
|
||||||
|
// We may want to ignore SSL
|
||||||
|
if (sender is HttpWebRequest)
|
||||||
{
|
{
|
||||||
HttpWebRequest Request = (HttpWebRequest)sender;
|
HttpWebRequest Request = (HttpWebRequest)sender;
|
||||||
|
ServicePoint sp = Request.ServicePoint;
|
||||||
|
|
||||||
|
// We don't case about encryption, get out of here
|
||||||
if (Request.Headers.Get("NoVerifyCert") != null)
|
if (Request.Headers.Get("NoVerifyCert") != null)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If there was an upstream cert verification error, bail
|
||||||
if ((((int)sslPolicyErrors) & ~4) != 0)
|
if ((((int)sslPolicyErrors) & ~4) != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// Check for policy and execute it if defined
|
||||||
if (ServicePointManager.CertificatePolicy != null)
|
if (ServicePointManager.CertificatePolicy != null)
|
||||||
{
|
{
|
||||||
ServicePoint sp = Request.ServicePoint;
|
|
||||||
return ServicePointManager.CertificatePolicy.CheckValidationResult (sp, certificate, Request, 0);
|
return ServicePointManager.CertificatePolicy.CheckValidationResult (sp, certificate, Request, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If it's not HTTP, trust .NET to check it
|
||||||
|
if ((((int)sslPolicyErrors) & ~4) != 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#region IHttpRequestModule Members
|
#region IHttpRequestModule Members
|
||||||
|
|
Loading…
Reference in New Issue