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
a0b78b88
Commit
a0b78b88
authored
Mar 09, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move all certificate related methods/properties to CertificateManager
parent
bb5a95a1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
489 additions
and
494 deletions
+489
-494
ProxyTestController.cs
.../Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
+2
-4
MainWindow.xaml.cs
Examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml.cs
+6
-10
README.md
README.md
+2
-2
SslTests.cs
Tests/Titanium.Web.Proxy.IntegrationTests/SslTests.cs
+0
-1
CertificateManagerTests.cs
...s/Titanium.Web.Proxy.UnitTests/CertificateManagerTests.cs
+37
-12
CertificateManager.cs
Titanium.Web.Proxy/Network/CertificateManager.cs
+414
-308
ProxyServer.cs
Titanium.Web.Proxy/ProxyServer.cs
+28
-157
No files found.
Examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
View file @
a0b78b88
...
...
@@ -32,20 +32,18 @@ namespace Titanium.Web.Proxy.Examples.Basic
proxyServer
=
new
ProxyServer
();
//generate root certificate without storing it in file system
//proxyServer.CertificateEngine = Network.CertificateEngine.BouncyCastle;
//proxyServer.CertificateManager.CreateTrustedRootCertificate(false);
//proxyServer.CertificateManager.TrustRootCertificate();
proxyServer
.
ExceptionFunc
=
exception
=>
Console
.
WriteLine
(
exception
.
Message
);
proxyServer
.
TrustRootCertificate
=
true
;
proxyServer
.
ForwardToUpstreamGateway
=
true
;
//optionally set the Certificate Engine
//Under Mono or Non-Windows runtimes only BouncyCastle will be supported
//proxyServer.Certificate
Engine = Network.CertificateEngine.DefaultWindows
;
//proxyServer.Certificate
Manager.CertificateEngine = Network.CertificateEngine.BouncyCastle
;
//optionally set the Root Certificate
//proxyServer.RootCertificate = new X509Certificate2("myCert.pfx", string.Empty, X509KeyStorageFlags.Exportable);
//proxyServer.
CertificateManager.
RootCertificate = new X509Certificate2("myCert.pfx", string.Empty, X509KeyStorageFlags.Exportable);
}
public
void
StartProxy
()
...
...
Examples/Titanium.Web.Proxy.Examples.Wpf/MainWindow.xaml.cs
View file @
a0b78b88
...
...
@@ -62,29 +62,25 @@ namespace Titanium.Web.Proxy.Examples.Wpf
public
MainWindow
()
{
proxyServer
=
new
ProxyServer
();
//proxyServer.CertificateEngine = CertificateEngine.DefaultWindows;
//proxyServer.Certificate
Manager.Certificate
Engine = CertificateEngine.DefaultWindows;
////Set a password for the .pfx file
//proxyServer.PfxPassword = "PfxPassword";
//proxyServer.
CertificateManager.
PfxPassword = "PfxPassword";
////Set Name(path) of the Root certificate file
//proxyServer.PfxFilePath = @"C:\NameFolder\rootCert.pfx";
//proxyServer.
CertificateManager.
PfxFilePath = @"C:\NameFolder\rootCert.pfx";
////do you want Replace an existing Root certificate file(.pfx) if password is incorrect(RootCertificate=null)? yes====>true
//proxyServer.OverwritePfxFile = true;
//proxyServer.
CertificateManager.
OverwritePfxFile = true;
////save all fake certificates in folder "crts"(will be created in proxy dll directory)
////if create new Root certificate file(.pfx) ====> delete folder "crts"
//proxyServer.SaveFakeCertificates = true;
//Trust Root Certificate
proxyServer
.
TrustRootCertificate
=
true
;
proxyServer
.
TrustRootCertificateAsAdministrator
=
true
;
//proxyServer.CertificateManager.SaveFakeCertificates = true;
proxyServer
.
ForwardToUpstreamGateway
=
true
;
////if you need Load or Create Certificate now. ////// "true" if you need Enable===> Trust the RootCertificate used by this proxy server
//proxyServer.EnsureRootCertificate(true);
//proxyServer.
CertificateManager.
EnsureRootCertificate(true);
////or load directly certificate(As Administrator if need this)
////and At the same time chose path and password
...
...
README.md
View file @
a0b78b88
...
...
@@ -52,11 +52,11 @@ Setup HTTP proxy:
var
proxyServer
=
new
ProxyServer
();
//locally trust root certificate used by this proxy
proxyServer
.
TrustRootCertificate
=
true
;
proxyServer
.
CertificateManager
.
TrustRootCertificate
=
true
;
//optionally set the Certificate Engine
//Under Mono only BouncyCastle will be supported
//proxyServer.CertificateEngine = Network.CertificateEngine.BouncyCastle;
//proxyServer.Certificate
Manager.Certificate
Engine = Network.CertificateEngine.BouncyCastle;
proxyServer
.
BeforeRequest
+=
OnRequest
;
proxyServer
.
BeforeResponse
+=
OnResponse
;
...
...
Tests/Titanium.Web.Proxy.IntegrationTests/SslTests.cs
View file @
a0b78b88
...
...
@@ -51,7 +51,6 @@ namespace Titanium.Web.Proxy.IntegrationTests
public
ProxyTestController
()
{
proxyServer
=
new
ProxyServer
();
proxyServer
.
TrustRootCertificate
=
true
;
}
public
void
StartProxy
(
int
proxyPort
)
...
...
Tests/Titanium.Web.Proxy.UnitTests/CertificateManagerTests.cs
View file @
a0b78b88
...
...
@@ -15,28 +15,53 @@ namespace Titanium.Web.Proxy.UnitTests
private
readonly
Random
random
=
new
Random
();
[
TestMethod
]
public
async
Task
Simple_Create_Certificate_
Stress_
Test
()
public
async
Task
Simple_Create_Certificate_Test
()
{
var
tasks
=
new
List
<
Task
>();
var
mgr
=
new
CertificateManager
(
new
Lazy
<
Action
<
Exception
>>(()
=>
(
e
=>
{
})).
Value
);
mgr
.
ClearIdleCertificates
(
1
);
mgr
.
ClearIdleCertificates
();
for
(
int
i
=
0
;
i
<
1000
;
i
++
)
for
each
(
string
host
in
hostNames
)
{
foreach
(
string
host
in
hostNames
)
tasks
.
Add
(
Task
.
Run
(
async
()
=>
{
tasks
.
Add
(
Task
.
Run
(
async
()
=>
{
await
Task
.
Delay
(
random
.
Next
(
0
,
10
)
*
100
);
//get the connection
var
certificate
=
await
mgr
.
CreateCertificateAsync
(
host
);
//get the connection
var
certificate
=
await
mgr
.
CreateCertificateAsync
(
host
);
Assert
.
IsNotNull
(
certificate
);
}));
}
Assert
.
IsNotNull
(
certificate
);
}));
}
await
Task
.
WhenAll
(
tasks
.
ToArray
());
mgr
.
StopClearIdleCertificates
();
}
//uncomment this to compare WinCert maker performance with BC (BC takes more time for same test above)
//cannot run this test in build server since trusting the certificate won't happen successfully
//[TestMethod]
public
async
Task
Simple_Create_Win_Certificate_Test
()
{
var
tasks
=
new
List
<
Task
>();
var
mgr
=
new
CertificateManager
(
new
Lazy
<
Action
<
Exception
>>(()
=>
(
e
=>
{
})).
Value
);
mgr
.
CreateRootCertificate
(
true
);
mgr
.
TrustRootCertificate
();
mgr
.
ClearIdleCertificates
();
mgr
.
CertificateEngine
=
CertificateEngine
.
DefaultWindows
;
foreach
(
string
host
in
hostNames
)
{
tasks
.
Add
(
Task
.
Run
(
async
()
=>
{
//get the connection
var
certificate
=
await
mgr
.
CreateCertificateAsync
(
host
);
Assert
.
IsNotNull
(
certificate
);
}));
}
await
Task
.
WhenAll
(
tasks
.
ToArray
());
...
...
Titanium.Web.Proxy/Network/CertificateManager.cs
View file @
a0b78b88
This diff is collapsed.
Click to expand it.
Titanium.Web.Proxy/ProxyServer.cs
View file @
a0b78b88
This diff is collapsed.
Click to expand it.
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