Commit 341c29ec authored by Jehonathan Thomas's avatar Jehonathan Thomas Committed by GitHub

Merge pull request #241 from justcoding121/develop

add TLS cert revocation check flag; cleanup
parents 6a66e7b1 83cca8a5
......@@ -229,7 +229,7 @@ namespace Titanium.Web.Proxy.Helpers
finally
{
tcpConnection.Dispose();
Interlocked.Decrement(ref server.ServerConnectionCountField);
Interlocked.Decrement(ref server.serverConnectionCount);
}
}
}
......
......@@ -95,12 +95,13 @@ namespace Titanium.Web.Proxy.Network.Tcp
sslStream = new SslStream(stream, true, server.ValidateServerCertificate,
server.SelectClientCertificate);
await sslStream.AuthenticateAsClientAsync(remoteHostName, null, server.SupportedSslProtocols, false);
await sslStream.AuthenticateAsClientAsync(remoteHostName, null, server.SupportedSslProtocols, server.CheckCertificateRevocation);
stream = new CustomBufferedStream(sslStream, server.BufferSize);
}
catch
{
sslStream?.Close();
sslStream?.Dispose();
throw;
......@@ -125,7 +126,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
client.ReceiveTimeout = server.ConnectionTimeOutSeconds * 1000;
client.SendTimeout = server.ConnectionTimeOutSeconds * 1000;
Interlocked.Increment(ref server.ServerConnectionCountField);
Interlocked.Increment(ref server.serverConnectionCount);
return new TcpConnection
{
......
......@@ -35,9 +35,20 @@ namespace Titanium.Web.Proxy
/// </summary>
private Action<Exception> exceptionFunc;
/// <summary>
/// Backing field for corresponding public property
/// </summary>
private bool trustRootCertificate;
private int clientConnectionCountField;
internal int ServerConnectionCountField;
/// <summary>
/// Backing field for corresponding public property
/// </summary>
private int clientConnectionCount;
/// <summary>
/// Backing field for corresponding public property
/// </summary>
internal int serverConnectionCount;
/// <summary>
/// A object that creates tcp connection to server
......@@ -127,6 +138,12 @@ namespace Titanium.Web.Proxy
set { CertificateManager.Engine = value; }
}
/// <summary>
/// Should we check for certificare revocation during SSL authentication to servers
/// Note: If enabled can reduce performance (Default disabled)
/// </summary>
public bool CheckCertificateRevocation { get; set; }
/// <summary>
/// Does this proxy uses the HTTP protocol 100 continue behaviour strictly?
/// Broken 100 contunue implementations on server/client may cause problems if enabled
......@@ -231,13 +248,13 @@ namespace Titanium.Web.Proxy
/// <summary>
/// Total number of active client connections
/// </summary>
public int ClientConnectionCount => clientConnectionCountField;
public int ClientConnectionCount => clientConnectionCount;
/// <summary>
/// Total number of active server connections
/// </summary>
public int ServerConnectionCount => ServerConnectionCountField;
public int ServerConnectionCount => serverConnectionCount;
/// <summary>
/// Constructor
......@@ -597,7 +614,10 @@ namespace Titanium.Web.Proxy
{
Task.Run(async () =>
{
Interlocked.Increment(ref clientConnectionCountField);
Interlocked.Increment(ref clientConnectionCount);
tcpClient.ReceiveTimeout = ConnectionTimeOutSeconds * 1000;
tcpClient.SendTimeout = ConnectionTimeOutSeconds * 1000;
try
{
......@@ -612,7 +632,7 @@ namespace Titanium.Web.Proxy
}
finally
{
Interlocked.Decrement(ref clientConnectionCountField);
Interlocked.Decrement(ref clientConnectionCount);
try
{
......
......@@ -36,9 +36,6 @@ namespace Titanium.Web.Proxy
var clientStream = new CustomBufferedStream(tcpClient.GetStream(), BufferSize);
clientStream.ReadTimeout = ConnectionTimeOutSeconds * 1000;
clientStream.WriteTimeout = ConnectionTimeOutSeconds * 1000;
var clientStreamReader = new CustomBinaryReader(clientStream, BufferSize);
var clientStreamWriter = new StreamWriter(clientStream) { NewLine = ProxyConstants.NewLine };
......@@ -187,9 +184,6 @@ namespace Titanium.Web.Proxy
bool disposed = false;
var clientStream = new CustomBufferedStream(tcpClient.GetStream(), BufferSize);
clientStream.ReadTimeout = ConnectionTimeOutSeconds * 1000;
clientStream.WriteTimeout = ConnectionTimeOutSeconds * 1000;
CustomBinaryReader clientStreamReader = null;
StreamWriter clientStreamWriter = null;
......
......@@ -49,7 +49,7 @@ namespace Titanium.Web.Proxy
if (args.WebSession.ServerConnection != null)
{
args.WebSession.ServerConnection.Dispose();
Interlocked.Decrement(ref ServerConnectionCountField);
Interlocked.Decrement(ref serverConnectionCount);
}
var connection = await GetServerConnection(args);
......@@ -240,7 +240,7 @@ namespace Titanium.Web.Proxy
if (serverConnection != null)
{
serverConnection.Dispose();
Interlocked.Decrement(ref ServerConnectionCountField);
Interlocked.Decrement(ref serverConnectionCount);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment