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
de0ec9c4
Commit
de0ec9c4
authored
Feb 06, 2016
by
titanium007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use certificate only if SSL is enabled
parent
9c6b022c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
23 deletions
+33
-23
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+33
-23
No files found.
Titanium.Web.Proxy/RequestHandler.cs
View file @
de0ec9c4
...
...
@@ -118,45 +118,55 @@ namespace Titanium.Web.Proxy
}
//This is called when requests are routed through router to this endpoint
//For ssl requests
private
static
void
HandleClient
(
TransparentProxyEndPoint
endPoint
,
TcpClient
tcpClient
)
{
var
sslStream
=
new
SslStream
(
tcpClient
.
GetStream
(),
true
);
Stream
clientStream
=
tcpClient
.
GetStream
(
);
CustomBinaryReader
clientStreamReader
=
null
;
StreamWriter
clientStreamWriter
=
null
;
X509Certificate2
certificate
=
null
;
//if(endPoint.UseServerNameIndication)
//{
// //implement in future once SNI supported by SSL stream
// certificate = CertManager.CreateCertificate(endPoint.GenericCertificateName);
//}
//else
certificate
=
CertManager
.
CreateCertificate
(
endPoint
.
GenericCertificateName
);
try
if
(
endPoint
.
EnableSsl
)
{
//Successfully managed to authenticate the client using the fake certificate
sslStream
.
AuthenticateAsServer
(
certificate
,
false
,
SslProtocols
.
Tls
,
false
);
var
sslStream
=
new
SslStream
(
clientStream
,
true
);
//if(endPoint.UseServerNameIndication)
//{
// //implement in future once SNI supported by SSL stream
// certificate = CertManager.CreateCertificate(endPoint.GenericCertificateName);
//}
//else
certificate
=
CertManager
.
CreateCertificate
(
endPoint
.
GenericCertificateName
);
try
{
//Successfully managed to authenticate the client using the fake certificate
sslStream
.
AuthenticateAsServer
(
certificate
,
false
,
SslProtocols
.
Tls
,
false
);
clientStreamReader
=
new
CustomBinaryReader
(
sslStream
,
Encoding
.
ASCII
);
clientStreamWriter
=
new
StreamWriter
(
sslStream
);
//HTTPS server created - we can now decrypt the client's traffic
clientStreamReader
=
new
CustomBinaryReader
(
sslStream
,
Encoding
.
ASCII
);
clientStreamWriter
=
new
StreamWriter
(
sslStream
);
//HTTPS server created - we can now decrypt the client's traffic
}
catch
(
Exception
)
{
if
(
sslStream
!=
null
)
sslStream
.
Dispose
();
Dispose
(
tcpClient
,
sslStream
,
clientStreamReader
,
clientStreamWriter
,
null
);
return
;
}
clientStream
=
sslStream
;
}
catch
(
Exception
)
else
{
if
(
sslStream
!=
null
)
sslStream
.
Dispose
();
Dispose
(
tcpClient
,
sslStream
,
clientStreamReader
,
clientStreamWriter
,
null
);
return
;
clientStreamReader
=
new
CustomBinaryReader
(
clientStream
,
Encoding
.
ASCII
);
}
var
httpCmd
=
clientStreamReader
.
ReadLine
();
//Now create the request
HandleHttpSessionRequest
(
tcpClient
,
httpCmd
,
ssl
Stream
,
clientStreamReader
,
clientStreamWriter
,
HandleHttpSessionRequest
(
tcpClient
,
httpCmd
,
client
Stream
,
clientStreamReader
,
clientStreamWriter
,
true
);
}
...
...
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