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
48e9de81
Commit
48e9de81
authored
Mar 08, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dictionary is thread safe (no lock needed); update BC
parent
5d778739
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
77 deletions
+65
-77
CertificateManager.cs
Titanium.Web.Proxy/Network/CertificateManager.cs
+37
-49
Titanium.Web.Proxy.csproj
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
+26
-26
Titanium.Web.Proxy.nuspec
Titanium.Web.Proxy/Titanium.Web.Proxy.nuspec
+1
-1
packages.config
Titanium.Web.Proxy/packages.config
+1
-1
No files found.
Titanium.Web.Proxy/Network/CertificateManager.cs
View file @
48e9de81
...
@@ -155,7 +155,7 @@ namespace Titanium.Web.Proxy.Network
...
@@ -155,7 +155,7 @@ namespace Titanium.Web.Proxy.Network
string
path
=
Path
.
GetDirectoryName
(
assemblyLocation
);
string
path
=
Path
.
GetDirectoryName
(
assemblyLocation
);
if
(
null
==
path
)
if
(
null
==
path
)
throw
new
NullReferenceException
();
throw
new
NullReferenceException
();
return
path
;
return
path
;
}
}
...
@@ -176,7 +176,7 @@ namespace Titanium.Web.Proxy.Network
...
@@ -176,7 +176,7 @@ namespace Titanium.Web.Proxy.Network
private
string
GetRootCertificatePath
()
private
string
GetRootCertificatePath
()
{
{
string
path
=
GetRootCertificateDirectory
();
string
path
=
GetRootCertificateDirectory
();
string
fileName
=
PfxFilePath
;
string
fileName
=
PfxFilePath
;
if
(
fileName
==
string
.
Empty
)
if
(
fileName
==
string
.
Empty
)
{
{
...
@@ -195,7 +195,7 @@ namespace Titanium.Web.Proxy.Network
...
@@ -195,7 +195,7 @@ namespace Titanium.Web.Proxy.Network
{
{
return
null
;
return
null
;
}
}
try
try
{
{
return
new
X509Certificate2
(
fileName
,
PfxPassword
,
StorageFlag
);
return
new
X509Certificate2
(
fileName
,
PfxPassword
,
StorageFlag
);
...
@@ -253,7 +253,7 @@ namespace Titanium.Web.Proxy.Network
...
@@ -253,7 +253,7 @@ namespace Titanium.Web.Proxy.Network
// ignore
// ignore
}
}
string
fileName
=
GetRootCertificatePath
();
string
fileName
=
GetRootCertificatePath
();
File
.
WriteAllBytes
(
fileName
,
RootCertificate
.
Export
(
X509ContentType
.
Pkcs12
,
PfxPassword
));
File
.
WriteAllBytes
(
fileName
,
RootCertificate
.
Export
(
X509ContentType
.
Pkcs12
,
PfxPassword
));
}
}
catch
(
Exception
e
)
catch
(
Exception
e
)
...
@@ -317,7 +317,7 @@ namespace Titanium.Web.Proxy.Network
...
@@ -317,7 +317,7 @@ namespace Titanium.Web.Proxy.Network
var
info
=
new
ProcessStartInfo
var
info
=
new
ProcessStartInfo
{
{
FileName
=
"certutil.exe"
,
FileName
=
"certutil.exe"
,
Arguments
=
"-importPFX -p \""
+
PfxPassword
+
"\" -f \""
+
fileName
+
"\""
,
Arguments
=
"-importPFX -p \""
+
PfxPassword
+
"\" -f \""
+
fileName
+
"\""
,
CreateNoWindow
=
true
,
CreateNoWindow
=
true
,
UseShellExecute
=
true
,
UseShellExecute
=
true
,
Verb
=
"runas"
,
Verb
=
"runas"
,
...
@@ -458,64 +458,52 @@ namespace Titanium.Web.Proxy.Network
...
@@ -458,64 +458,52 @@ namespace Titanium.Web.Proxy.Network
}
}
X509Certificate2
certificate
=
null
;
X509Certificate2
certificate
=
null
;
lock
(
string
.
Intern
(
certificateName
))
try
{
{
if
(
certificateCache
.
ContainsKey
(
certificateName
)
==
false
)
if
(
!
isRootCertificate
&&
SaveFakeCertificates
)
{
{
try
string
path
=
GetCertPath
();
string
subjectName
=
BCCertificateMaker
.
CNRemoverRegex
.
Replace
(
certificateName
,
string
.
Empty
);
subjectName
=
subjectName
.
Replace
(
"*"
,
"$x$"
);
subjectName
=
Path
.
Combine
(
path
,
subjectName
+
".pfx"
);
if
(!
File
.
Exists
(
subjectName
))
{
certificate
=
MakeCertificate
(
certificateName
,
isRootCertificate
);
File
.
WriteAllBytes
(
subjectName
,
certificate
.
Export
(
X509ContentType
.
Pkcs12
));
}
else
{
{
if
(!
isRootCertificate
&&
SaveFakeCertificates
)
try
{
{
string
path
=
GetCertPath
();
certificate
=
new
X509Certificate2
(
subjectName
,
string
.
Empty
,
StorageFlag
);
string
subjectName
=
BCCertificateMaker
.
CNRemoverRegex
.
Replace
(
certificateName
,
string
.
Empty
);
subjectName
=
subjectName
.
Replace
(
"*"
,
"$x$"
);
subjectName
=
Path
.
Combine
(
path
,
subjectName
+
".pfx"
);
if
(!
File
.
Exists
(
subjectName
))
{
certificate
=
MakeCertificate
(
certificateName
,
isRootCertificate
);
File
.
WriteAllBytes
(
subjectName
,
certificate
.
Export
(
X509ContentType
.
Pkcs12
));
}
else
{
try
{
certificate
=
new
X509Certificate2
(
subjectName
,
string
.
Empty
,
StorageFlag
);
}
catch
/* (Exception e)*/
{
certificate
=
MakeCertificate
(
certificateName
,
isRootCertificate
);
}
}
}
}
else
catch
/* (Exception e)*/
{
{
certificate
=
MakeCertificate
(
certificateName
,
isRootCertificate
);
certificate
=
MakeCertificate
(
certificateName
,
isRootCertificate
);
}
}
}
}
catch
(
Exception
e
)
{
exceptionFunc
(
e
);
}
if
(
certificate
!=
null
&&
!
certificateCache
.
ContainsKey
(
certificateName
))
{
certificateCache
.
Add
(
certificateName
,
new
CachedCertificate
{
Certificate
=
certificate
});
}
}
}
else
else
{
{
if
(
certificateCache
.
ContainsKey
(
certificateName
))
certificate
=
MakeCertificate
(
certificateName
,
isRootCertificate
);
{
var
cached
=
certificateCache
[
certificateName
];
cached
.
LastAccess
=
DateTime
.
Now
;
return
cached
.
Certificate
;
}
}
}
}
}
catch
(
Exception
e
)
{
exceptionFunc
(
e
);
}
if
(
certificate
!=
null
)
{
//this is ConcurrentDictionary
//if key exists it will silently handle; no need for locking
certificateCache
.
Add
(
certificateName
,
new
CachedCertificate
{
Certificate
=
certificate
});
}
return
certificate
;
return
certificate
;
}
}
...
...
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
View file @
48e9de81
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PropertyGroup>
<TargetFrameworks>net45;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net45;netstandard2.0</TargetFrameworks>
<RootNamespace>Titanium.Web.Proxy</RootNamespace>
<RootNamespace>Titanium.Web.Proxy</RootNamespace>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<SignAssembly>True</SignAssembly>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>StrongNameKey.snk</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyFile>StrongNameKey.snk</AssemblyOriginatorKeyFile>
<DelaySign>False</DelaySign>
<DelaySign>False</DelaySign>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<LangVersion>7.1</LangVersion>
<LangVersion>7.1</LangVersion>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<PackageReference Include="Portable.BouncyCastle" Version="1.8.1.
3" />
<PackageReference Include="Portable.BouncyCastle" Version="1.8.1.
4" />
<PackageReference Include="StreamExtended" Version="1.0.135-beta" />
<PackageReference Include="StreamExtended" Version="1.0.135-beta" />
</ItemGroup>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Win32.Registry">
<PackageReference Include="Microsoft.Win32.Registry">
<Version>4.4.0</Version>
<Version>4.4.0</Version>
</PackageReference>
</PackageReference>
<PackageReference Include="System.Security.Principal.Windows">
<PackageReference Include="System.Security.Principal.Windows">
<Version>4.4.1</Version>
<Version>4.4.1</Version>
</PackageReference>
</PackageReference>
</ItemGroup>
</ItemGroup>
</Project>
</Project>
\ No newline at end of file
Titanium.Web.Proxy/Titanium.Web.Proxy.nuspec
View file @
48e9de81
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
<tags></tags>
<tags></tags>
<dependencies>
<dependencies>
<dependency
id=
"StreamExtended"
version=
"1.0.110-beta"
/>
<dependency
id=
"StreamExtended"
version=
"1.0.110-beta"
/>
<dependency
id=
"Portable.BouncyCastle"
version=
"1.8.1.
3
"
/>
<dependency
id=
"Portable.BouncyCastle"
version=
"1.8.1.
4
"
/>
</dependencies>
</dependencies>
</metadata>
</metadata>
<files>
<files>
...
...
Titanium.Web.Proxy/packages.config
View file @
48e9de81
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
packages
>
<
package
id
=
"Portable.BouncyCastle"
version
=
"1.8.1.
3
"
targetFramework
=
"net45"
/>
<
package
id
=
"Portable.BouncyCastle"
version
=
"1.8.1.
4
"
targetFramework
=
"net45"
/>
<
package
id
=
"StreamExtended"
version
=
"1.0.110-beta"
targetFramework
=
"net45"
/>
<
package
id
=
"StreamExtended"
version
=
"1.0.110-beta"
targetFramework
=
"net45"
/>
</
packages
>
</
packages
>
\ No newline at end of file
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