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
0f910b1a
Unverified
Commit
0f910b1a
authored
Feb 14, 2019
by
Jehonathan Thomas
Committed by
GitHub
Feb 14, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #551 from jmh76/issue-550
Issue 550
parents
771ccfb4
3d73a6bd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
19 deletions
+34
-19
ProxyConnectException.cs
src/Titanium.Web.Proxy/Exceptions/ProxyConnectException.cs
+4
-4
ProxyHttpException.cs
src/Titanium.Web.Proxy/Exceptions/ProxyHttpException.cs
+4
-4
ExplicitClientHandler.cs
src/Titanium.Web.Proxy/ExplicitClientHandler.cs
+9
-5
TransparentClientHandler.cs
src/Titanium.Web.Proxy/TransparentClientHandler.cs
+17
-6
No files found.
src/Titanium.Web.Proxy/Exceptions/ProxyConnectException.cs
View file @
0f910b1a
...
...
@@ -13,11 +13,11 @@ namespace Titanium.Web.Proxy.Exceptions
/// </summary>
/// <param name="message">Message for this exception</param>
/// <param name="innerException">Associated inner exception</param>
/// <param name="
connectEventArgs
">Instance of <see cref="EventArguments.TunnelConnectSessionEventArgs" /> associated to the exception</param>
internal
ProxyConnectException
(
string
message
,
Exception
innerException
,
TunnelConnectSessionEventArgs
connectEventArgs
)
:
base
(
/// <param name="
session
">Instance of <see cref="EventArguments.TunnelConnectSessionEventArgs" /> associated to the exception</param>
internal
ProxyConnectException
(
string
message
,
Exception
innerException
,
SessionEventArgsBase
session
)
:
base
(
message
,
innerException
)
{
ConnectEventArgs
=
connectEventArgs
;
Session
=
session
;
}
/// <summary>
...
...
@@ -26,6 +26,6 @@ namespace Titanium.Web.Proxy.Exceptions
/// <remarks>
/// This object properties should not be edited.
/// </remarks>
public
TunnelConnectSessionEventArgs
ConnectEventArgs
{
get
;
}
public
SessionEventArgsBase
Session
{
get
;
}
}
}
src/Titanium.Web.Proxy/Exceptions/ProxyHttpException.cs
View file @
0f910b1a
...
...
@@ -13,11 +13,11 @@ namespace Titanium.Web.Proxy.Exceptions
/// </summary>
/// <param name="message">Message for this exception</param>
/// <param name="innerException">Associated inner exception</param>
/// <param name="session
EventArgs
">Instance of <see cref="EventArguments.SessionEventArgs" /> associated to the exception</param>
internal
ProxyHttpException
(
string
message
,
Exception
innerException
,
SessionEventArgs
session
EventArgs
)
:
base
(
/// <param name="session">Instance of <see cref="EventArguments.SessionEventArgs" /> associated to the exception</param>
internal
ProxyHttpException
(
string
message
,
Exception
innerException
,
SessionEventArgs
session
)
:
base
(
message
,
innerException
)
{
Session
EventArgs
=
sessionEventArgs
;
Session
=
session
;
}
/// <summary>
...
...
@@ -26,6 +26,6 @@ namespace Titanium.Web.Proxy.Exceptions
/// <remarks>
/// This object properties should not be edited.
/// </remarks>
public
SessionEventArgs
Session
EventArgs
{
get
;
}
public
SessionEventArgs
Session
{
get
;
}
}
}
src/Titanium.Web.Proxy/ExplicitClientHandler.cs
View file @
0f910b1a
...
...
@@ -161,13 +161,13 @@ namespace Titanium.Web.Proxy
cancellationToken
:
CancellationToken
.
None
);
}
X509Certificate2
certificate
=
null
;
try
{
sslStream
=
new
SslStream
(
clientStream
);
sslStream
=
new
SslStream
(
clientStream
,
true
);
string
certName
=
HttpHelper
.
GetWildCardDomainName
(
connectHostname
);
var
certificate
=
endPoint
.
GenericCertificate
??
certificate
=
endPoint
.
GenericCertificate
??
await
CertificateManager
.
CreateServerCertificate
(
certName
);
// Successfully managed to authenticate the client using the fake certificate
...
...
@@ -197,9 +197,13 @@ namespace Titanium.Web.Proxy
}
catch
(
Exception
e
)
{
sslStream
?.
Dispose
(
);
var
certname
=
certificate
?.
GetNameInfo
(
X509NameType
.
SimpleName
,
false
);
throw
new
ProxyConnectException
(
$"Could'nt authenticate client '
{
connectHostname
}
' with fake certificate."
,
e
,
connectArgs
);
$"Couldn't authenticate host '
{
connectHostname
}
' with certificate '
{
certname
}
'."
,
e
,
connectArgs
);
}
finally
{
sslStream
?.
Dispose
();
}
if
(
await
HttpHelper
.
IsConnectMethod
(
clientStream
)
==
-
1
)
...
...
src/Titanium.Web.Proxy/TransparentClientHandler.cs
View file @
0f910b1a
...
...
@@ -4,6 +4,7 @@ using System.IO;
using
System.Net.Security
;
using
System.Net.Sockets
;
using
System.Security.Authentication
;
using
System.Security.Cryptography.X509Certificates
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
StreamExtended
;
...
...
@@ -62,16 +63,17 @@ namespace Titanium.Web.Proxy
SslStream
sslStream
=
null
;
//do client authentication using fake certificate
//do client authentication using certificate
X509Certificate2
certificate
=
null
;
try
{
sslStream
=
new
SslStream
(
clientStream
);
sslStream
=
new
SslStream
(
clientStream
,
true
);
string
certName
=
HttpHelper
.
GetWildCardDomainName
(
httpsHostName
);
var
certificate
=
endPoint
.
GenericCertificate
??
certificate
=
endPoint
.
GenericCertificate
??
await
CertificateManager
.
CreateServerCertificate
(
certName
);
// Successfully managed to authenticate the client using the
fake
certificate
// Successfully managed to authenticate the client using the certificate
await
sslStream
.
AuthenticateAsServerAsync
(
certificate
,
false
,
SslProtocols
.
Tls
,
false
);
// HTTPS server created - we can now decrypt the client's traffic
...
...
@@ -81,9 +83,18 @@ namespace Titanium.Web.Proxy
}
catch
(
Exception
e
)
{
sslStream
?.
Dispose
();
var
certname
=
certificate
?.
GetNameInfo
(
X509NameType
.
SimpleName
,
false
);
var
session
=
new
SessionEventArgs
(
this
,
endPoint
,
cancellationTokenSource
)
{
ProxyClient
=
{
Connection
=
clientConnection
},
HttpClient
=
{
ConnectRequest
=
null
}
};
throw
new
ProxyConnectException
(
$"Could'nt authenticate client '
{
httpsHostName
}
' with fake certificate."
,
e
,
null
);
$"Couldn't authenticate host '
{
httpsHostName
}
' with certificate '
{
certname
}
'."
,
e
,
session
);
}
finally
{
sslStream
?.
Dispose
();
}
}
else
...
...
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