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
8eca0091
Commit
8eca0091
authored
Mar 11, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update tests
parent
95900411
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
34 deletions
+23
-34
CertificateManagerTests.cs
...s/Titanium.Web.Proxy.UnitTests/CertificateManagerTests.cs
+21
-23
WinCertificateMaker.cs
...nium.Web.Proxy/Network/Certificate/WinCertificateMaker.cs
+2
-11
No files found.
Tests/Titanium.Web.Proxy.UnitTests/CertificateManagerTests.cs
View file @
8eca0091
...
...
@@ -15,25 +15,23 @@ namespace Titanium.Web.Proxy.UnitTests
private
readonly
Random
random
=
new
Random
();
[
TestMethod
]
public
async
Task
Simple_Create_Certificate_Test
()
public
async
Task
Simple_
BC_
Create_Certificate_Test
()
{
var
tasks
=
new
List
<
Task
>();
var
mgr
=
new
CertificateManager
(
new
Lazy
<
Action
<
Exception
>>(()
=>
(
e
=>
{
})).
Value
);
mgr
.
CertificateEngine
=
CertificateEngine
.
BouncyCastle
;
mgr
.
ClearIdleCertificates
();
foreach
(
string
host
in
hostNames
)
{
tasks
.
Add
(
Task
.
Run
(
async
()
=>
for
(
int
i
=
0
;
i
<
5
;
i
++)
foreach
(
string
host
in
hostNames
)
{
tasks
.
Add
(
Task
.
Run
(()
=>
{
//get the connection
var
certificate
=
await
mgr
.
CreateCertificateAsync
(
host
);
Assert
.
IsNotNull
(
certificate
);
}));
}
var
certificate
=
mgr
.
CreateCertificate
(
host
,
false
);
Assert
.
IsNotNull
(
certificate
);
}));
}
await
Task
.
WhenAll
(
tasks
.
ToArray
());
...
...
@@ -42,27 +40,27 @@ namespace Titanium.Web.Proxy.UnitTests
//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]
[
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
.
CertificateEngine
=
CertificateEngine
.
DefaultWindows
;
mgr
.
CreateRootCertificate
(
true
);
mgr
.
TrustRootCertificate
();
mgr
.
TrustRootCertificate
AsAdmin
();
mgr
.
ClearIdleCertificates
();
mgr
.
CertificateEngine
=
CertificateEngine
.
DefaultWindows
;
foreach
(
string
host
in
hostNames
)
{
tasks
.
Add
(
Task
.
Run
(
async
()
=>
for
(
int
i
=
0
;
i
<
5
;
i
++)
foreach
(
string
host
in
hostNames
)
{
tasks
.
Add
(
Task
.
Run
(()
=>
{
//get the connection
var
certificate
=
await
mgr
.
CreateCertificateAsync
(
host
);
Assert
.
IsNotNull
(
certificate
);
}));
}
var
certificate
=
mgr
.
CreateCertificate
(
host
,
false
);
Assert
.
IsNotNull
(
certificate
);
}));
}
await
Task
.
WhenAll
(
tasks
.
ToArray
());
...
...
Titanium.Web.Proxy/Network/Certificate/WinCertificateMaker.cs
View file @
8eca0091
...
...
@@ -250,17 +250,8 @@ namespace Titanium.Web.Proxy.Network.Certificate
typeX509Enrollment
.
InvokeMember
(
"InstallResponse"
,
BindingFlags
.
InvokeMethod
,
null
,
x509Enrollment
,
typeValue
);
typeValue
=
new
object
[]
{
null
,
0
,
1
};
try
{
string
empty
=
(
string
)
typeX509Enrollment
.
InvokeMember
(
"CreatePFX"
,
BindingFlags
.
InvokeMethod
,
null
,
x509Enrollment
,
typeValue
);
return
new
X509Certificate2
(
Convert
.
FromBase64String
(
empty
),
string
.
Empty
,
X509KeyStorageFlags
.
Exportable
);
}
catch
(
Exception
)
{
// ignored
}
return
null
;
string
empty
=
(
string
)
typeX509Enrollment
.
InvokeMember
(
"CreatePFX"
,
BindingFlags
.
InvokeMethod
,
null
,
x509Enrollment
,
typeValue
);
return
new
X509Certificate2
(
Convert
.
FromBase64String
(
empty
),
string
.
Empty
,
X509KeyStorageFlags
.
Exportable
);
}
private
X509Certificate2
MakeCertificateInternal
(
string
sSubjectCN
,
bool
isRoot
,
...
...
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