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
41fb34f3
Commit
41fb34f3
authored
Mar 13, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove await parellel
parent
4e8c68f5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
33 deletions
+15
-33
CertificateHandler.cs
Titanium.Web.Proxy/CertificateHandler.cs
+2
-2
FuncExtensions.cs
Titanium.Web.Proxy/Extensions/FuncExtensions.cs
+0
-25
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+13
-6
No files found.
Titanium.Web.Proxy/CertificateHandler.cs
View file @
41fb34f3
...
@@ -29,7 +29,7 @@ namespace Titanium.Web.Proxy
...
@@ -29,7 +29,7 @@ namespace Titanium.Web.Proxy
};
};
//why is the sender null?
//why is the sender null?
ServerCertificateValidationCallback
.
Invoke
Parallel
(
this
,
args
);
ServerCertificateValidationCallback
.
Invoke
Async
(
this
,
args
,
exceptionFunc
).
Wait
(
);
return
args
.
IsValid
;
return
args
.
IsValid
;
}
}
...
@@ -88,7 +88,7 @@ namespace Titanium.Web.Proxy
...
@@ -88,7 +88,7 @@ namespace Titanium.Web.Proxy
};
};
//why is the sender null?
//why is the sender null?
ClientCertificateSelectionCallback
.
Invoke
Parallel
(
this
,
args
);
ClientCertificateSelectionCallback
.
Invoke
Async
(
this
,
args
,
exceptionFunc
).
Wait
(
);
return
args
.
ClientCertificate
;
return
args
.
ClientCertificate
;
}
}
...
...
Titanium.Web.Proxy/Extensions/FuncExtensions.cs
View file @
41fb34f3
...
@@ -6,31 +6,6 @@ namespace Titanium.Web.Proxy.Extensions
...
@@ -6,31 +6,6 @@ namespace Titanium.Web.Proxy.Extensions
{
{
internal
static
class
FuncExtensions
internal
static
class
FuncExtensions
{
{
public
static
void
InvokeParallel
<
T
>(
this
AsyncEventHandler
<
T
>
callback
,
object
sender
,
T
args
)
{
var
invocationList
=
callback
.
GetInvocationList
();
var
handlerTasks
=
new
Task
[
invocationList
.
Length
];
for
(
int
i
=
0
;
i
<
invocationList
.
Length
;
i
++)
{
handlerTasks
[
i
]
=
((
AsyncEventHandler
<
T
>)
invocationList
[
i
])(
sender
,
args
);
}
Task
.
WhenAll
(
handlerTasks
).
Wait
();
}
public
static
async
Task
InvokeParallelAsync
<
T
>(
this
AsyncEventHandler
<
T
>
callback
,
object
sender
,
T
args
,
Action
<
Exception
>
exceptionFunc
)
{
var
invocationList
=
callback
.
GetInvocationList
();
var
handlerTasks
=
new
Task
[
invocationList
.
Length
];
for
(
int
i
=
0
;
i
<
invocationList
.
Length
;
i
++)
{
handlerTasks
[
i
]
=
InternalInvokeAsync
((
AsyncEventHandler
<
T
>)
invocationList
[
i
],
sender
,
args
,
exceptionFunc
);
}
await
Task
.
WhenAll
(
handlerTasks
);
}
public
static
async
Task
InvokeAsync
<
T
>(
this
AsyncEventHandler
<
T
>
callback
,
object
sender
,
T
args
,
Action
<
Exception
>
exceptionFunc
)
public
static
async
Task
InvokeAsync
<
T
>(
this
AsyncEventHandler
<
T
>
callback
,
object
sender
,
T
args
,
Action
<
Exception
>
exceptionFunc
)
{
{
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
41fb34f3
...
@@ -128,8 +128,9 @@ namespace Titanium.Web.Proxy
...
@@ -128,8 +128,9 @@ namespace Titanium.Web.Proxy
clientStreamReader
=
new
CustomBinaryReader
(
clientStream
,
BufferSize
);
clientStreamReader
=
new
CustomBinaryReader
(
clientStream
,
BufferSize
);
clientStreamWriter
=
new
HttpResponseWriter
(
clientStream
,
BufferSize
);
clientStreamWriter
=
new
HttpResponseWriter
(
clientStream
,
BufferSize
);
}
}
catch
catch
(
Exception
e
)
{
{
ExceptionFunc
(
new
Exception
(
$"Could'nt authenticate client '
{
connectHostname
}
' with fake certificate."
,
e
));
sslStream
?.
Dispose
();
sslStream
?.
Dispose
();
return
;
return
;
}
}
...
@@ -233,13 +234,19 @@ namespace Titanium.Web.Proxy
...
@@ -233,13 +234,19 @@ namespace Titanium.Web.Proxy
var
sslStream
=
new
SslStream
(
clientStream
);
var
sslStream
=
new
SslStream
(
clientStream
);
clientStream
=
new
CustomBufferedStream
(
sslStream
,
BufferSize
);
clientStream
=
new
CustomBufferedStream
(
sslStream
,
BufferSize
);
string
sniHostName
=
clientHelloInfo
.
GetServerName
();
string
sniHostName
=
clientHelloInfo
.
GetServerName
()
??
endPoint
.
GenericCertificateName
;
string
certName
=
HttpHelper
.
GetWildCardDomainName
(
sniHostName
??
endPoint
.
GenericCertificateName
);
string
certName
=
HttpHelper
.
GetWildCardDomainName
(
sniHostName
);
var
certificate
=
await
CertificateManager
.
CreateCertificateAsync
(
certName
);
var
certificate
=
await
CertificateManager
.
CreateCertificateAsync
(
certName
);
try
//Successfully managed to authenticate the client using the fake certificate
{
await
sslStream
.
AuthenticateAsServerAsync
(
certificate
,
false
,
SslProtocols
.
Tls
,
false
);
//Successfully managed to authenticate the client using the fake certificate
await
sslStream
.
AuthenticateAsServerAsync
(
certificate
,
false
,
SslProtocols
.
Tls
,
false
);
}
catch
(
Exception
e
)
{
ExceptionFunc
(
new
Exception
(
$"Could'nt authenticate client '
{
sniHostName
}
' with fake certificate."
,
e
));
}
}
}
//HTTPS server created - we can now decrypt the client's traffic
//HTTPS server created - we can now decrypt the client's traffic
...
...
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