add SSL certs validation options for robust to allow simple certificates, possible only for encriptation without any peer autentification. disable validation by default for the small grids case

This commit is contained in:
UbitUmarov
2016-12-07 12:23:40 +00:00
parent 4993a08d25
commit 049dd374e9
2 changed files with 36 additions and 0 deletions

View File

@@ -30,6 +30,8 @@ using log4net;
using System.Reflection;
using System;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Collections.Generic;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
@@ -51,6 +53,26 @@ namespace OpenSim.Server
new List<IServiceConnector>();
protected static PluginLoader loader;
private static bool m_NoVerifyCertChain = false;
private static bool m_NoVerifyCertHostname = false;
public static bool ValidateServerCertificate(
object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors)
{
if (m_NoVerifyCertChain)
sslPolicyErrors &= ~SslPolicyErrors.RemoteCertificateChainErrors;
if (m_NoVerifyCertHostname)
sslPolicyErrors &= ~SslPolicyErrors.RemoteCertificateNameMismatch;
if (sslPolicyErrors == SslPolicyErrors.None)
return true;
return false;
}
public static int Main(string[] args)
{
@@ -69,6 +91,11 @@ namespace OpenSim.Server
throw new Exception("Configuration error");
}
m_NoVerifyCertChain = serverConfig.GetBoolean("NoVerifyCertChain", m_NoVerifyCertChain);
m_NoVerifyCertHostname = serverConfig.GetBoolean("NoVerifyCertHostname", m_NoVerifyCertHostname);
ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate;
string connList = serverConfig.GetString("ServiceConnectors", String.Empty);
registryLocation = serverConfig.GetString("RegistryLocation",".");