diff --git a/.vscode/launch.json b/.vscode/launch.json
index 20840235b..a7ca58048 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -5,7 +5,7 @@
"name": "NetCore|Debug|Basic Example",
"type": "coreclr",
"request": "launch",
- "program": "${workspaceRoot}/examples/Titanium.Web.Proxy.Examples.Basic/bin/Debug/netcoreapp2.0/Titanium.Web.Proxy.Examples.Basic.NetCore.dll",
+ "program": "${workspaceRoot}/examples/Titanium.Web.Proxy.Examples.Basic/bin/Debug/netcoreapp3.1/Titanium.Web.Proxy.Examples.Basic.NetCore.dll",
"args": [],
"cwd": "${workspaceRoot}",
"stopAtEntry": false,
@@ -16,7 +16,7 @@
"name": "NetCore|Release|Basic Example",
"type": "coreclr",
"request": "launch",
- "program": "${workspaceRoot}/examples/Titanium.Web.Proxy.Examples.Basic/bin/Release/netcoreapp2.0/Titanium.Web.Proxy.Examples.Basic.NetCore.dll",
+ "program": "${workspaceRoot}/examples/Titanium.Web.Proxy.Examples.Basic/bin/Release/netcoreapp3.1/Titanium.Web.Proxy.Examples.Basic.NetCore.dll",
"args": [],
"cwd": "${workspaceRoot}",
"stopAtEntry": false,
diff --git a/examples/Titanium.Web.Proxy.Examples.Basic/Titanium.Web.Proxy.Examples.Basic.NetCore.csproj b/examples/Titanium.Web.Proxy.Examples.Basic/Titanium.Web.Proxy.Examples.Basic.NetCore.csproj
index 4744326f0..2d250e8df 100644
--- a/examples/Titanium.Web.Proxy.Examples.Basic/Titanium.Web.Proxy.Examples.Basic.NetCore.csproj
+++ b/examples/Titanium.Web.Proxy.Examples.Basic/Titanium.Web.Proxy.Examples.Basic.NetCore.csproj
@@ -2,7 +2,7 @@
Exe
- netcoreapp2.1
+ netcoreapp3.1
false
7.1
diff --git a/examples/Titanium.Web.Proxy.Examples.Basic/Titanium.Web.Proxy.Examples.Basic.csproj b/examples/Titanium.Web.Proxy.Examples.Basic/Titanium.Web.Proxy.Examples.Basic.csproj
index d924886a0..5bd979326 100644
--- a/examples/Titanium.Web.Proxy.Examples.Basic/Titanium.Web.Proxy.Examples.Basic.csproj
+++ b/examples/Titanium.Web.Proxy.Examples.Basic/Titanium.Web.Proxy.Examples.Basic.csproj
@@ -2,7 +2,7 @@
Exe
- net461;netcoreapp3.0
+ net461;netcoreapp3.1
false
7.1
diff --git a/examples/Titanium.Web.Proxy.Examples.WindowsService/Titanium.Web.Proxy.Examples.WindowsService.csproj b/examples/Titanium.Web.Proxy.Examples.WindowsService/Titanium.Web.Proxy.Examples.WindowsService.csproj
index a035141b6..de3e324bc 100644
--- a/examples/Titanium.Web.Proxy.Examples.WindowsService/Titanium.Web.Proxy.Examples.WindowsService.csproj
+++ b/examples/Titanium.Web.Proxy.Examples.WindowsService/Titanium.Web.Proxy.Examples.WindowsService.csproj
@@ -103,16 +103,16 @@
- 4.6.0
+ 4.7.0
4.5.0
- 4.6.0
+ 4.7.0
- 4.6.0
+ 4.7.0
4.5.3
diff --git a/examples/Titanium.Web.Proxy.Examples.Wpf/Titanium.Web.Proxy.Examples.Wpf.NetCore.csproj b/examples/Titanium.Web.Proxy.Examples.Wpf/Titanium.Web.Proxy.Examples.Wpf.NetCore.csproj
index 2379187e2..5964493db 100644
--- a/examples/Titanium.Web.Proxy.Examples.Wpf/Titanium.Web.Proxy.Examples.Wpf.NetCore.csproj
+++ b/examples/Titanium.Web.Proxy.Examples.Wpf/Titanium.Web.Proxy.Examples.Wpf.NetCore.csproj
@@ -2,7 +2,7 @@
WinExe
- netcoreapp3.0
+ netcoreapp3.1
true
diff --git a/examples/Titanium.Web.Proxy.Examples.Wpf/Titanium.Web.Proxy.Examples.Wpf.csproj b/examples/Titanium.Web.Proxy.Examples.Wpf/Titanium.Web.Proxy.Examples.Wpf.csproj
index 89dd81498..ccf8d5a78 100644
--- a/examples/Titanium.Web.Proxy.Examples.Wpf/Titanium.Web.Proxy.Examples.Wpf.csproj
+++ b/examples/Titanium.Web.Proxy.Examples.Wpf/Titanium.Web.Proxy.Examples.Wpf.csproj
@@ -2,7 +2,7 @@
WinExe
- net461;netcoreapp3.0
+ net461;netcoreapp3.1
true
diff --git a/src/Titanium.Web.Proxy/EventArguments/EmptyProxyEventArgs.cs b/src/Titanium.Web.Proxy/EventArguments/EmptyProxyEventArgs.cs
new file mode 100644
index 000000000..81d95d8c0
--- /dev/null
+++ b/src/Titanium.Web.Proxy/EventArguments/EmptyProxyEventArgs.cs
@@ -0,0 +1,12 @@
+using System;
+using Titanium.Web.Proxy.Network.Tcp;
+
+namespace Titanium.Web.Proxy.EventArguments
+{
+ public class EmptyProxyEventArgs : ProxyEventArgsBase
+ {
+ internal EmptyProxyEventArgs(TcpClientConnection clientConnection) : base(clientConnection)
+ {
+ }
+ }
+}
diff --git a/src/Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs b/src/Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
index c55803426..f39658fe7 100644
--- a/src/Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
+++ b/src/Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
@@ -190,7 +190,7 @@ private async Task readResponseBodyAsync(CancellationToken cancellationToken)
private async Task readBodyAsync(bool isRequest, CancellationToken cancellationToken)
{
using var bodyStream = new MemoryStream();
- using var writer = new HttpStream(bodyStream, BufferPool);
+ using var writer = new HttpStream(bodyStream, BufferPool, cancellationToken);
if (isRequest)
{
diff --git a/src/Titanium.Web.Proxy/ExplicitClientHandler.cs b/src/Titanium.Web.Proxy/ExplicitClientHandler.cs
index ac0baa6c5..a17597e0c 100644
--- a/src/Titanium.Web.Proxy/ExplicitClientHandler.cs
+++ b/src/Titanium.Web.Proxy/ExplicitClientHandler.cs
@@ -33,14 +33,12 @@ private async Task handleClient(ExplicitProxyEndPoint endPoint, TcpClientConnect
var cancellationTokenSource = new CancellationTokenSource();
var cancellationToken = cancellationTokenSource.Token;
- var clientStream = new HttpClientStream(clientConnection, clientConnection.GetStream(), BufferPool);
+ var clientStream = new HttpClientStream(clientConnection, clientConnection.GetStream(), BufferPool, cancellationToken);
Task? prefetchConnectionTask = null;
bool closeServerConnection = false;
bool calledRequestHandler = false;
- SslStream? sslStream = null;
-
try
{
TunnelConnectSessionEventArgs? connectArgs = null;
@@ -191,6 +189,7 @@ private async Task handleClient(ExplicitProxyEndPoint endPoint, TcpClientConnect
}
X509Certificate2? certificate = null;
+ SslStream? sslStream = null;
try
{
sslStream = new SslStream(clientStream, false);
@@ -221,7 +220,7 @@ private async Task handleClient(ExplicitProxyEndPoint endPoint, TcpClientConnect
#endif
// HTTPS server created - we can now decrypt the client's traffic
- clientStream = new HttpClientStream(clientStream.Connection, sslStream, BufferPool);
+ clientStream = new HttpClientStream(clientStream.Connection, sslStream, BufferPool, cancellationToken);
sslStream = null; // clientStream was created, no need to keep SSL stream reference
clientStream.DataRead += (o, args) => connectArgs.OnDecryptedDataSent(args.Buffer, args.Offset, args.Count);
@@ -229,6 +228,8 @@ private async Task handleClient(ExplicitProxyEndPoint endPoint, TcpClientConnect
}
catch (Exception e)
{
+ sslStream?.Dispose();
+
var certName = certificate?.GetNameInfo(X509NameType.SimpleName, false);
throw new ProxyConnectException(
$"Couldn't authenticate host '{connectHostname}' with certificate '{certName}'.", e, connectArgs);
@@ -401,12 +402,16 @@ await Http2Helper.SendHttp2(clientStream, connection.Stream,
}
finally
{
+ if (!cancellationTokenSource.IsCancellationRequested)
+ {
+ cancellationTokenSource.Cancel();
+ }
+
if (!calledRequestHandler)
{
await tcpConnectionFactory.Release(prefetchConnectionTask, closeServerConnection);
}
- sslStream?.Dispose();
clientStream.Dispose();
}
}
diff --git a/src/Titanium.Web.Proxy/Extensions/StreamExtensions.cs b/src/Titanium.Web.Proxy/Extensions/StreamExtensions.cs
index 4e3c5ecfa..bbe52459b 100644
--- a/src/Titanium.Web.Proxy/Extensions/StreamExtensions.cs
+++ b/src/Titanium.Web.Proxy/Extensions/StreamExtensions.cs
@@ -42,8 +42,8 @@ internal static async Task CopyToAsync(this Stream input, Stream output, Action<
{
// cancellation is not working on Socket ReadAsync
// https://github.com/dotnet/corefx/issues/15033
- int num = await input.ReadAsync(buffer, 0, buffer.Length, CancellationToken.None)
- .withCancellation(cancellationToken);
+ int num = await input.ReadAsync(buffer, 0, buffer.Length, cancellationToken)
+ .WithCancellation(cancellationToken);
int bytesRead;
if ((bytesRead = num) != 0 && !cancellationToken.IsCancellationRequested)
{
@@ -62,7 +62,7 @@ internal static async Task CopyToAsync(this Stream input, Stream output, Action<
}
}
- private static async Task withCancellation(this Task task, CancellationToken cancellationToken) where T : struct
+ internal static async Task WithCancellation(this Task task, CancellationToken cancellationToken) where T : struct
{
var tcs = new TaskCompletionSource();
using (cancellationToken.Register(s => ((TaskCompletionSource)s).TrySetResult(true), tcs))
diff --git a/src/Titanium.Web.Proxy/Helpers/HttpClientStream.cs b/src/Titanium.Web.Proxy/Helpers/HttpClientStream.cs
index e816ba44f..594635e36 100644
--- a/src/Titanium.Web.Proxy/Helpers/HttpClientStream.cs
+++ b/src/Titanium.Web.Proxy/Helpers/HttpClientStream.cs
@@ -12,8 +12,8 @@ internal sealed class HttpClientStream : HttpStream
{
public TcpClientConnection Connection { get; }
- internal HttpClientStream(TcpClientConnection connection, Stream stream, IBufferPool bufferPool)
- : base(stream, bufferPool)
+ internal HttpClientStream(TcpClientConnection connection, Stream stream, IBufferPool bufferPool, CancellationToken cancellationToken)
+ : base(stream, bufferPool, cancellationToken)
{
Connection = connection;
}
diff --git a/src/Titanium.Web.Proxy/Helpers/HttpServerStream.cs b/src/Titanium.Web.Proxy/Helpers/HttpServerStream.cs
index df2b94c9a..a4f08f99f 100644
--- a/src/Titanium.Web.Proxy/Helpers/HttpServerStream.cs
+++ b/src/Titanium.Web.Proxy/Helpers/HttpServerStream.cs
@@ -10,8 +10,8 @@ namespace Titanium.Web.Proxy.Helpers
{
internal sealed class HttpServerStream : HttpStream
{
- internal HttpServerStream(Stream stream, IBufferPool bufferPool)
- : base(stream, bufferPool)
+ internal HttpServerStream(Stream stream, IBufferPool bufferPool, CancellationToken cancellationToken)
+ : base(stream, bufferPool, cancellationToken)
{
}
diff --git a/src/Titanium.Web.Proxy/Helpers/HttpStream.cs b/src/Titanium.Web.Proxy/Helpers/HttpStream.cs
index 82505dd85..22a8a7aa4 100644
--- a/src/Titanium.Web.Proxy/Helpers/HttpStream.cs
+++ b/src/Titanium.Web.Proxy/Helpers/HttpStream.cs
@@ -9,6 +9,7 @@
using System.Threading.Tasks;
using Titanium.Web.Proxy.Compression;
using Titanium.Web.Proxy.EventArguments;
+using Titanium.Web.Proxy.Extensions;
using Titanium.Web.Proxy.Http;
using Titanium.Web.Proxy.Models;
using Titanium.Web.Proxy.Shared;
@@ -19,7 +20,7 @@ namespace Titanium.Web.Proxy.Helpers
{
internal class HttpStream : Stream, IHttpStreamWriter, IHttpStreamReader, IPeekStream
{
- private readonly bool swallowException;
+ private readonly bool isNetworkStream;
private readonly bool leaveOpen;
private readonly byte[] streamBuffer;
@@ -37,6 +38,7 @@ internal class HttpStream : Stream, IHttpStreamWriter, IHttpStreamReader, IPeekS
private bool closedRead;
private readonly IBufferPool bufferPool;
+ private readonly CancellationToken cancellationToken;
public event EventHandler? DataRead;
@@ -71,18 +73,20 @@ static HttpStream()
///
/// The base stream.
/// Bufferpool.
+ /// The cancellation token.
/// to leave the stream open after disposing the object; otherwise, .
- internal HttpStream(Stream baseStream, IBufferPool bufferPool, bool leaveOpen = false)
+ internal HttpStream(Stream baseStream, IBufferPool bufferPool, CancellationToken cancellationToken, bool leaveOpen = false)
{
if (baseStream is NetworkStream)
{
- swallowException = true;
+ isNetworkStream = true;
}
this.baseStream = baseStream;
this.leaveOpen = leaveOpen;
streamBuffer = bufferPool.GetBuffer();
this.bufferPool = bufferPool;
+ this.cancellationToken = cancellationToken;
}
///
@@ -102,7 +106,7 @@ public override void Flush()
catch
{
closedWrite = true;
- if (!swallowException)
+ if (!isNetworkStream)
throw;
}
}
@@ -181,7 +185,7 @@ public override void Write(byte[] buffer, int offset, int count)
catch
{
closedWrite = true;
- if (!swallowException)
+ if (!isNetworkStream)
throw;
}
}
@@ -228,7 +232,7 @@ public override async Task FlushAsync(CancellationToken cancellationToken)
catch
{
closedWrite = true;
- if (!swallowException)
+ if (!isNetworkStream)
throw;
}
}
@@ -450,7 +454,7 @@ public override async Task WriteAsync(byte[] buffer, int offset, int count, Canc
catch
{
closedWrite = true;
- if (!swallowException)
+ if (!isNetworkStream)
throw;
}
}
@@ -476,7 +480,7 @@ public override void WriteByte(byte value)
catch
{
closedWrite = true;
- if (!swallowException)
+ if (!isNetworkStream)
throw;
}
finally
@@ -609,7 +613,7 @@ public bool FillBuffer()
}
catch
{
- if (!swallowException)
+ if (!isNetworkStream)
throw;
}
finally
@@ -655,7 +659,13 @@ public async ValueTask FillBufferAsync(CancellationToken cancellationToken
bool result = false;
try
{
- int readBytes = await baseStream.ReadAsync(streamBuffer, bufferLength, bytesToRead, cancellationToken);
+ var readTask = baseStream.ReadAsync(streamBuffer, bufferLength, bytesToRead, cancellationToken);
+ if (isNetworkStream)
+ {
+ readTask = readTask.WithCancellation(cancellationToken);
+ }
+
+ int readBytes = await readTask;
result = readBytes > 0;
if (result)
{
@@ -665,7 +675,7 @@ public async ValueTask FillBufferAsync(CancellationToken cancellationToken
}
catch
{
- if (!swallowException)
+ if (!isNetworkStream)
throw;
}
finally
@@ -771,14 +781,18 @@ public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, Asy
return base.BeginRead(buffer, offset, count, callback, state);
}
- var vAsyncResult = this.ReadAsync(buffer, offset, count);
+ var vAsyncResult = this.ReadAsync(buffer, offset, count, cancellationToken);
+ if (isNetworkStream)
+ {
+ vAsyncResult = vAsyncResult.WithCancellation(cancellationToken);
+ }
vAsyncResult.ContinueWith(pAsyncResult =>
{
// use TaskExtended to pass State as AsyncObject
// callback will call EndRead (otherwise, it will block)
callback?.Invoke(new TaskResult(pAsyncResult, state));
- });
+ }, cancellationToken);
return vAsyncResult;
}
@@ -811,12 +825,12 @@ public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, As
return base.BeginWrite(buffer, offset, count, callback, state);
}
- var vAsyncResult = this.WriteAsync(buffer, offset, count);
+ var vAsyncResult = this.WriteAsync(buffer, offset, count, cancellationToken);
vAsyncResult.ContinueWith(pAsyncResult =>
{
callback?.Invoke(new TaskResult(pAsyncResult, state));
- });
+ }, cancellationToken);
return vAsyncResult;
}
@@ -868,7 +882,7 @@ private async ValueTask writeAsyncInternal(string value, bool addNewLine, Cancel
catch
{
closedWrite = true;
- if (!swallowException)
+ if (!isNetworkStream)
throw;
}
finally
@@ -893,7 +907,7 @@ private async ValueTask writeAsyncInternal(string value, bool addNewLine, Cancel
catch
{
closedWrite = true;
- if (!swallowException)
+ if (!isNetworkStream)
throw;
}
}
@@ -940,7 +954,7 @@ internal async ValueTask WriteAsync(byte[] data, bool flush = false, Cancellatio
catch
{
closedWrite = true;
- if (!swallowException)
+ if (!isNetworkStream)
throw;
}
}
@@ -964,7 +978,7 @@ internal async Task WriteAsync(byte[] data, int offset, int count, bool flush,
catch
{
closedWrite = true;
- if (!swallowException)
+ if (!isNetworkStream)
throw;
}
}
@@ -1011,7 +1025,7 @@ public async Task CopyBodyAsync(RequestResponseBase requestResponse, bool useOri
try
{
- var http = new HttpStream(s, bufferPool, true);
+ var http = new HttpStream(s, bufferPool, cancellationToken, true);
await http.CopyBodyAsync(writer, false, -1, onCopy, cancellationToken);
}
finally
@@ -1196,7 +1210,7 @@ public override async ValueTask WriteAsync(ReadOnlyMemory buffer, Cancella
catch
{
closedWrite = true;
- if (!swallowException)
+ if (!isNetworkStream)
throw;
}
}
@@ -1217,7 +1231,7 @@ public async Task WriteAsync(ReadOnlyMemory buffer, CancellationToken canc
}
catch
{
- if (!swallowException)
+ if (!isNetworkStream)
throw;
}
}
diff --git a/src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs b/src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
index ba310332b..bc2c028d7 100644
--- a/src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
+++ b/src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs
@@ -445,7 +445,7 @@ private async Task createServerConnection(string remoteHost
await proxyServer.InvokeServerConnectionCreateEvent(tcpClient);
- stream = new HttpServerStream(tcpClient.GetStream(), proxyServer.BufferPool);
+ stream = new HttpServerStream(tcpClient.GetStream(), proxyServer.BufferPool, cancellationToken);
if (externalProxy != null && (isConnect || isHttps))
{
@@ -487,7 +487,7 @@ private async Task createServerConnection(string remoteHost
(sender, targetHost, localCertificates, remoteCertificate, acceptableIssuers) =>
proxyServer.SelectClientCertificate(sender, sessionArgs, targetHost, localCertificates,
remoteCertificate, acceptableIssuers));
- stream = new HttpServerStream(sslStream, proxyServer.BufferPool);
+ stream = new HttpServerStream(sslStream, proxyServer.BufferPool, cancellationToken);
var options = new SslClientAuthenticationOptions
{
diff --git a/src/Titanium.Web.Proxy/RequestHandler.cs b/src/Titanium.Web.Proxy/RequestHandler.cs
index feb41f4fc..18ddedb5f 100644
--- a/src/Titanium.Web.Proxy/RequestHandler.cs
+++ b/src/Titanium.Web.Proxy/RequestHandler.cs
@@ -272,7 +272,7 @@ private async Task handleHttpSessionRequest(SessionEventArgs args,
cancellationToken);
// for connection pool, retry fails until cache is exhausted.
- return await retryPolicy().ExecuteAsync(async (connection) =>
+ return await retryPolicy().ExecuteAsync(async connection =>
{
// set the connection and send request headers
args.HttpClient.SetConnection(connection);
diff --git a/src/Titanium.Web.Proxy/Titanium.Web.Proxy.NetCore.csproj b/src/Titanium.Web.Proxy/Titanium.Web.Proxy.NetCore.csproj
index de71aa587..8bd384189 100644
--- a/src/Titanium.Web.Proxy/Titanium.Web.Proxy.NetCore.csproj
+++ b/src/Titanium.Web.Proxy/Titanium.Web.Proxy.NetCore.csproj
@@ -1,37 +1,28 @@
- netstandard2.0;netcoreapp2.1
+ netstandard2.1
Titanium.Web.Proxy
false
True
StrongNameKey.snk
False
True
+ enable
8.0
-
-
+
- 4.6.0
+ 4.7.0
- 4.6.0
-
-
-
-
-
- 4.6.0
-
-
- 4.6.0
+ 4.7.0
diff --git a/src/Titanium.Web.Proxy/Titanium.Web.Proxy.csproj b/src/Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
index 6a8b943ca..e665ae3d4 100644
--- a/src/Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
+++ b/src/Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
@@ -25,10 +25,10 @@
- 4.6.0
+ 4.7.0
- 4.6.0
+ 4.7.0
diff --git a/src/Titanium.Web.Proxy/Titanium.Web.Proxy.nuspec b/src/Titanium.Web.Proxy/Titanium.Web.Proxy.nuspec
index 07d33b737..54faceebd 100644
--- a/src/Titanium.Web.Proxy/Titanium.Web.Proxy.nuspec
+++ b/src/Titanium.Web.Proxy/Titanium.Web.Proxy.nuspec
@@ -24,26 +24,26 @@
-
+
-
+
-
+
-
+
-
-
+
+
diff --git a/src/Titanium.Web.Proxy/TransparentClientHandler.cs b/src/Titanium.Web.Proxy/TransparentClientHandler.cs
index e91f1ded8..0c8342aa3 100644
--- a/src/Titanium.Web.Proxy/TransparentClientHandler.cs
+++ b/src/Titanium.Web.Proxy/TransparentClientHandler.cs
@@ -30,9 +30,7 @@ private async Task handleClient(TransparentProxyEndPoint endPoint, TcpClientConn
var cancellationTokenSource = new CancellationTokenSource();
var cancellationToken = cancellationTokenSource.Token;
- var clientStream = new HttpClientStream(clientConnection, clientConnection.GetStream(), BufferPool);
-
- SslStream? sslStream = null;
+ var clientStream = new HttpClientStream(clientConnection, clientConnection.GetStream(), BufferPool, cancellationToken);
try
{
@@ -57,6 +55,7 @@ private async Task handleClient(TransparentProxyEndPoint endPoint, TcpClientConn
// do client authentication using certificate
X509Certificate2? certificate = null;
+ SslStream? sslStream = null;
try
{
sslStream = new SslStream(clientStream, false);
@@ -69,17 +68,18 @@ private async Task handleClient(TransparentProxyEndPoint endPoint, TcpClientConn
await sslStream.AuthenticateAsServerAsync(certificate, false, SslProtocols.Tls, false);
// HTTPS server created - we can now decrypt the client's traffic
- clientStream = new HttpClientStream(clientStream.Connection, sslStream, BufferPool);
+ clientStream = new HttpClientStream(clientStream.Connection, sslStream, BufferPool, cancellationToken);
sslStream = null; // clientStream was created, no need to keep SSL stream reference
}
catch (Exception e)
{
+ sslStream?.Dispose();
+
var certName = certificate?.GetNameInfo(X509NameType.SimpleName, false);
var session = new SessionEventArgs(this, endPoint, clientStream, null, cancellationTokenSource);
throw new ProxyConnectException(
$"Couldn't authenticate host '{httpsHostName}' with certificate '{certName}'.", e, session);
}
-
}
else
{
@@ -146,7 +146,6 @@ await TcpHelper.SendRaw(clientStream, connection.Stream, BufferPool,
}
finally
{
- sslStream?.Dispose();
clientStream.Dispose();
}
}
diff --git a/tests/Titanium.Web.Proxy.IntegrationTests/Titanium.Web.Proxy.IntegrationTests.csproj b/tests/Titanium.Web.Proxy.IntegrationTests/Titanium.Web.Proxy.IntegrationTests.csproj
index a6b38e20d..ec24902b5 100644
--- a/tests/Titanium.Web.Proxy.IntegrationTests/Titanium.Web.Proxy.IntegrationTests.csproj
+++ b/tests/Titanium.Web.Proxy.IntegrationTests/Titanium.Web.Proxy.IntegrationTests.csproj
@@ -1,7 +1,7 @@
- netcoreapp3.0
+ netcoreapp3.1
StrongNameKey.snk
true
@@ -14,9 +14,7 @@
-
-
-
+