Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Titanium-Web-Proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Titanium-Web-Proxy
Commits
92fa402d
Commit
92fa402d
authored
Feb 14, 2019
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move sslstream dispose to end to be safe
parent
0f910b1a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
14 deletions
+9
-14
ExplicitClientHandler.cs
src/Titanium.Web.Proxy/ExplicitClientHandler.cs
+4
-7
TransparentClientHandler.cs
src/Titanium.Web.Proxy/TransparentClientHandler.cs
+5
-7
No files found.
src/Titanium.Web.Proxy/ExplicitClientHandler.cs
View file @
92fa402d
...
@@ -41,11 +41,13 @@ namespace Titanium.Web.Proxy
...
@@ -41,11 +41,13 @@ namespace Titanium.Web.Proxy
bool
closeServerConnection
=
false
;
bool
closeServerConnection
=
false
;
bool
calledRequestHandler
=
false
;
bool
calledRequestHandler
=
false
;
SslStream
sslStream
=
null
;
try
try
{
{
string
connectHostname
=
null
;
string
connectHostname
=
null
;
TunnelConnectSessionEventArgs
connectArgs
=
null
;
TunnelConnectSessionEventArgs
connectArgs
=
null
;
// Client wants to create a secure tcp tunnel (probably its a HTTPS or Websocket request)
// Client wants to create a secure tcp tunnel (probably its a HTTPS or Websocket request)
if
(
await
HttpHelper
.
IsConnectMethod
(
clientStream
)
==
1
)
if
(
await
HttpHelper
.
IsConnectMethod
(
clientStream
)
==
1
)
...
@@ -150,8 +152,6 @@ namespace Titanium.Web.Proxy
...
@@ -150,8 +152,6 @@ namespace Titanium.Web.Proxy
await
tcpConnectionFactory
.
Release
(
connection
,
true
);
await
tcpConnectionFactory
.
Release
(
connection
,
true
);
}
}
SslStream
sslStream
=
null
;
if
(
EnableTcpServerConnectionPrefetch
)
if
(
EnableTcpServerConnectionPrefetch
)
{
{
//don't pass cancellation token here
//don't pass cancellation token here
...
@@ -201,10 +201,6 @@ namespace Titanium.Web.Proxy
...
@@ -201,10 +201,6 @@ namespace Titanium.Web.Proxy
throw
new
ProxyConnectException
(
throw
new
ProxyConnectException
(
$"Couldn't authenticate host '
{
connectHostname
}
' with certificate '
{
certname
}
'."
,
e
,
connectArgs
);
$"Couldn't authenticate host '
{
connectHostname
}
' with certificate '
{
certname
}
'."
,
e
,
connectArgs
);
}
}
finally
{
sslStream
?.
Dispose
();
}
if
(
await
HttpHelper
.
IsConnectMethod
(
clientStream
)
==
-
1
)
if
(
await
HttpHelper
.
IsConnectMethod
(
clientStream
)
==
-
1
)
{
{
...
@@ -354,6 +350,7 @@ namespace Titanium.Web.Proxy
...
@@ -354,6 +350,7 @@ namespace Titanium.Web.Proxy
await
tcpConnectionFactory
.
Release
(
prefetchConnectionTask
,
closeServerConnection
);
await
tcpConnectionFactory
.
Release
(
prefetchConnectionTask
,
closeServerConnection
);
}
}
sslStream
?.
Dispose
();
clientStream
.
Dispose
();
clientStream
.
Dispose
();
if
(!
cancellationTokenSource
.
IsCancellationRequested
)
if
(!
cancellationTokenSource
.
IsCancellationRequested
)
...
...
src/Titanium.Web.Proxy/TransparentClientHandler.cs
View file @
92fa402d
...
@@ -35,6 +35,8 @@ namespace Titanium.Web.Proxy
...
@@ -35,6 +35,8 @@ namespace Titanium.Web.Proxy
var
clientStream
=
new
CustomBufferedStream
(
clientConnection
.
GetStream
(),
BufferPool
,
BufferSize
);
var
clientStream
=
new
CustomBufferedStream
(
clientConnection
.
GetStream
(),
BufferPool
,
BufferSize
);
var
clientStreamWriter
=
new
HttpResponseWriter
(
clientStream
,
BufferPool
,
BufferSize
);
var
clientStreamWriter
=
new
HttpResponseWriter
(
clientStream
,
BufferPool
,
BufferSize
);
SslStream
sslStream
=
null
;
try
try
{
{
var
clientHelloInfo
=
await
SslTools
.
PeekClientHello
(
clientStream
,
BufferPool
,
cancellationToken
);
var
clientHelloInfo
=
await
SslTools
.
PeekClientHello
(
clientStream
,
BufferPool
,
cancellationToken
);
...
@@ -61,8 +63,6 @@ namespace Titanium.Web.Proxy
...
@@ -61,8 +63,6 @@ namespace Titanium.Web.Proxy
if
(
endPoint
.
DecryptSsl
&&
args
.
DecryptSsl
)
if
(
endPoint
.
DecryptSsl
&&
args
.
DecryptSsl
)
{
{
SslStream
sslStream
=
null
;
//do client authentication using certificate
//do client authentication using certificate
X509Certificate2
certificate
=
null
;
X509Certificate2
certificate
=
null
;
try
try
...
@@ -92,10 +92,7 @@ namespace Titanium.Web.Proxy
...
@@ -92,10 +92,7 @@ namespace Titanium.Web.Proxy
throw
new
ProxyConnectException
(
throw
new
ProxyConnectException
(
$"Couldn't authenticate host '
{
httpsHostName
}
' with certificate '
{
certname
}
'."
,
e
,
session
);
$"Couldn't authenticate host '
{
httpsHostName
}
' with certificate '
{
certname
}
'."
,
e
,
session
);
}
}
finally
{
sslStream
?.
Dispose
();
}
}
}
else
else
{
{
...
@@ -161,8 +158,9 @@ namespace Titanium.Web.Proxy
...
@@ -161,8 +158,9 @@ namespace Titanium.Web.Proxy
}
}
finally
finally
{
{
sslStream
?.
Dispose
();
clientStream
.
Dispose
();
clientStream
.
Dispose
();
if
(!
cancellationTokenSource
.
IsCancellationRequested
)
if
(!
cancellationTokenSource
.
IsCancellationRequested
)
{
{
cancellationTokenSource
.
Cancel
();
cancellationTokenSource
.
Cancel
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment