mirror of
https://github.com/MTSGJ/opensim.currency.git
synced 2026-07-28 05:13:05 +00:00
first
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
diff -Nur HttpServer.orig/HttpClientContext.cs HttpServer/HttpClientContext.cs
|
||||
--- HttpServer.orig/HttpClientContext.cs 2016-07-23 11:49:36.242240234 +0900
|
||||
+++ HttpServer/HttpClientContext.cs 2016-07-23 11:52:31.801952465 +0900
|
||||
@@ -6,6 +6,10 @@
|
||||
using HttpServer.Exceptions;
|
||||
using HttpServer.Parser;
|
||||
|
||||
+// by Fumi.Iseki
|
||||
+using System.Net.Security;
|
||||
+using System.Security.Cryptography.X509Certificates;
|
||||
+
|
||||
namespace HttpServer
|
||||
{
|
||||
/// <summary>
|
||||
@@ -92,6 +96,18 @@
|
||||
_sock = sock;
|
||||
_buffer = new byte[bufferSize];
|
||||
|
||||
+ // by Fumi.Iseki
|
||||
+ SSLCommonName = "";
|
||||
+ if (secured)
|
||||
+ {
|
||||
+ SslStream _ssl = (SslStream)_stream;
|
||||
+ X509Certificate _cert1 = _ssl.RemoteCertificate;
|
||||
+ if (_cert1 != null)
|
||||
+ {
|
||||
+ X509Certificate2 _cert2 = new X509Certificate2(_cert1);
|
||||
+ if (_cert2 != null) SSLCommonName = _cert2.GetNameInfo(X509NameType.SimpleName, false);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
public bool EndWhenDone
|
||||
@@ -215,6 +231,11 @@
|
||||
/// </summary>
|
||||
public bool IsSecured { get; internal set; }
|
||||
|
||||
+ //
|
||||
+ //
|
||||
+ // by Fumi.Iseki
|
||||
+ public string SSLCommonName { get; internal set; }
|
||||
+
|
||||
/// <summary>
|
||||
/// Specify which logger to use.
|
||||
/// </summary>
|
||||
diff -Nur HttpServer.orig/HttpContextFactory.cs HttpServer/HttpContextFactory.cs
|
||||
--- HttpServer.orig/HttpContextFactory.cs 2016-07-23 11:49:36.242240234 +0900
|
||||
+++ HttpServer/HttpContextFactory.cs 2016-07-23 11:52:32.648951102 +0900
|
||||
@@ -20,6 +20,10 @@
|
||||
private readonly ILogWriter _logWriter;
|
||||
private readonly ContextTimeoutManager _contextTimeoutManager;
|
||||
|
||||
+ // by Fumi.Iseki
|
||||
+ public static RemoteCertificateValidationCallback ClientCertificateValidationCallback = null;
|
||||
+ private RemoteCertificateValidationCallback _clientCallback = null;
|
||||
+
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HttpContextFactory"/> class.
|
||||
/// </summary>
|
||||
@@ -32,6 +36,13 @@
|
||||
_bufferSize = bufferSize;
|
||||
_factory = factory;
|
||||
_contextTimeoutManager = new ContextTimeoutManager(ContextTimeoutManager.MonitorType.Thread);
|
||||
+
|
||||
+ // by Fumi.Iseki
|
||||
+ if (ClientCertificateValidationCallback != null)
|
||||
+ {
|
||||
+ _clientCallback = ClientCertificateValidationCallback;
|
||||
+ ClientCertificateValidationCallback = null;
|
||||
+ }
|
||||
}
|
||||
|
||||
///<summary>
|
||||
@@ -132,11 +143,25 @@
|
||||
var networkStream = new ReusableSocketNetworkStream(socket, true);
|
||||
var remoteEndPoint = (IPEndPoint) socket.RemoteEndPoint;
|
||||
|
||||
- var sslStream = new SslStream(networkStream, false);
|
||||
+ // by Fumi.Iseki
|
||||
+ //var sslStream = new SslStream(networkStream, false);
|
||||
+ SslStream sslStream = null;
|
||||
try
|
||||
{
|
||||
//TODO: this may fail
|
||||
- sslStream.AuthenticateAsServer(certificate, false, protocol, false);
|
||||
+ // by Fumi.Iseki
|
||||
+ //sslStream.AuthenticateAsServer(certificate, false, protocol, false);
|
||||
+ if (_clientCallback == null)
|
||||
+ {
|
||||
+ sslStream = new SslStream(networkStream, false);
|
||||
+ sslStream.AuthenticateAsServer(certificate, false, protocol, false);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ sslStream = new SslStream(networkStream, false, new RemoteCertificateValidationCallback(_clientCallback));
|
||||
+ sslStream.AuthenticateAsServer(certificate, true, protocol, false);
|
||||
+ }
|
||||
+
|
||||
return CreateContext(true, remoteEndPoint, sslStream, socket);
|
||||
}
|
||||
catch (IOException err)
|
||||
diff -Nur HttpServer.orig/IHttpClientContext.cs HttpServer/IHttpClientContext.cs
|
||||
--- HttpServer.orig/IHttpClientContext.cs 2016-07-23 11:49:36.245240228 +0900
|
||||
+++ HttpServer/IHttpClientContext.cs 2016-07-23 11:52:33.369949910 +0900
|
||||
@@ -9,6 +9,11 @@
|
||||
/// </summary>
|
||||
public interface IHttpClientContext
|
||||
{
|
||||
+ //
|
||||
+ //
|
||||
+ // by Fumi.Iseki
|
||||
+ string SSLCommonName { get; }
|
||||
+
|
||||
/// <summary>
|
||||
/// Using SSL or other encryption method.
|
||||
/// </summary>
|
||||
Reference in New Issue
Block a user