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
db39e8e7
Commit
db39e8e7
authored
Jan 14, 2020
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
do not create cert path when not needed
parent
6f57a319
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
DefaultCertificateDiskCache.cs
...Titanium.Web.Proxy/Network/DefaultCertificateDiskCache.cs
+11
-7
No files found.
src/Titanium.Web.Proxy/Network/DefaultCertificateDiskCache.cs
View file @
db39e8e7
...
...
@@ -30,14 +30,14 @@ namespace Titanium.Web.Proxy.Network
/// <inheritdoc />
public
X509Certificate2
?
LoadCertificate
(
string
subjectName
,
X509KeyStorageFlags
storageFlags
)
{
string
path
=
Path
.
Combine
(
getCertificatePath
(
),
subjectName
+
defaultCertificateFileExtension
);
return
loadCertificate
(
p
ath
,
string
.
Empty
,
storageFlags
);
string
filePath
=
Path
.
Combine
(
getCertificatePath
(
false
),
subjectName
+
defaultCertificateFileExtension
);
return
loadCertificate
(
fileP
ath
,
string
.
Empty
,
storageFlags
);
}
/// <inheritdoc />
public
void
SaveCertificate
(
string
subjectName
,
X509Certificate2
certificate
)
{
string
filePath
=
Path
.
Combine
(
getCertificatePath
(),
subjectName
+
defaultCertificateFileExtension
);
string
filePath
=
Path
.
Combine
(
getCertificatePath
(
true
),
subjectName
+
defaultCertificateFileExtension
);
byte
[]
exported
=
certificate
.
Export
(
X509ContentType
.
Pkcs12
);
File
.
WriteAllBytes
(
filePath
,
exported
);
}
...
...
@@ -46,9 +46,13 @@ namespace Titanium.Web.Proxy.Network
{
try
{
Directory
.
Delete
(
getCertificatePath
(),
true
);
string
path
=
getCertificatePath
(
false
);
if
(
Directory
.
Exists
(
path
))
{
Directory
.
Delete
(
path
,
true
);
}
}
catch
(
DirectoryNotFound
Exception
)
catch
(
Exception
)
{
// do nothing
}
...
...
@@ -89,14 +93,14 @@ namespace Titanium.Web.Proxy.Network
string
.
IsNullOrEmpty
(
pathOrName
)
?
defaultRootCertificateFileName
:
pathOrName
);
}
private
string
getCertificatePath
()
private
string
getCertificatePath
(
bool
create
)
{
if
(
certificatePath
==
null
)
{
string
path
=
getRootCertificateDirectory
();
string
certPath
=
Path
.
Combine
(
path
,
defaultCertificateDirectoryName
);
if
(!
Directory
.
Exists
(
certPath
))
if
(
create
&&
!
Directory
.
Exists
(
certPath
))
{
Directory
.
CreateDirectory
(
certPath
);
}
...
...
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