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
cf8674e9
Commit
cf8674e9
authored
May 06, 2017
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ArgumentException fix when proxy dll is loaded dynamically
parent
ebd9284b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
7 deletions
+17
-7
CertificateManager.cs
Titanium.Web.Proxy/Network/CertificateManager.cs
+17
-7
No files found.
Titanium.Web.Proxy/Network/CertificateManager.cs
View file @
cf8674e9
...
...
@@ -34,6 +34,7 @@ namespace Titanium.Web.Proxy.Network
private
readonly
ICertificateMaker
certEngine
;
private
bool
clearCertificates
{
get
;
set
;
}
/// <summary>
/// Cache dictionary
/// </summary>
...
...
@@ -70,17 +71,29 @@ namespace Titanium.Web.Proxy.Network
certificateCache
=
new
ConcurrentDictionary
<
string
,
CachedCertificate
>();
}
internal
X509Certificate2
GetRootCertificate
()
private
string
GetRootCertificatePath
()
{
var
assemblyLocation
=
System
.
Reflection
.
Assembly
.
GetExecutingAssembly
().
Location
;
// dynamically loaded assemblies returns string.Empty location
if
(
assemblyLocation
==
string
.
Empty
)
{
var
path
=
Path
.
GetDirectoryName
(
System
.
Reflection
.
Assembly
.
GetExecutingAssembly
().
Location
);
assemblyLocation
=
System
.
Reflection
.
Assembly
.
GetEntryAssembly
().
Location
;
}
var
path
=
Path
.
GetDirectoryName
(
assemblyLocation
);
if
(
null
==
path
)
throw
new
NullReferenceException
();
var
fileName
=
Path
.
Combine
(
path
,
"rootCert.pfx"
);
return
fileName
;
}
internal
X509Certificate2
GetRootCertificate
()
{
var
fileName
=
GetRootCertificatePath
();
if
(!
File
.
Exists
(
fileName
))
return
null
;
try
{
return
new
X509Certificate2
(
fileName
,
string
.
Empty
,
X509KeyStorageFlags
.
Exportable
);
}
catch
(
Exception
e
)
{
...
...
@@ -94,7 +107,6 @@ namespace Titanium.Web.Proxy.Network
/// <returns>true if succeeded, else false</returns>
internal
bool
CreateTrustedRootCertificate
()
{
rootCertificate
=
GetRootCertificate
();
if
(
rootCertificate
!=
null
)
{
...
...
@@ -112,9 +124,7 @@ namespace Titanium.Web.Proxy.Network
{
try
{
var
path
=
Path
.
GetDirectoryName
(
System
.
Reflection
.
Assembly
.
GetExecutingAssembly
().
Location
);
if
(
null
==
path
)
throw
new
NullReferenceException
();
var
fileName
=
Path
.
Combine
(
path
,
"rootCert.pfx"
);
var
fileName
=
GetRootCertificatePath
();
File
.
WriteAllBytes
(
fileName
,
rootCertificate
.
Export
(
X509ContentType
.
Pkcs12
));
}
catch
(
Exception
e
)
...
...
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