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
1ea7f3eb
Commit
1ea7f3eb
authored
Apr 29, 2017
by
justcoding121
Committed by
justcoding121
Apr 29, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#180 Add cert to local machine store
parent
0779f209
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
21 deletions
+42
-21
Titanium.Web.Proxy.Examples.Basic.csproj
...y.Examples.Basic/Titanium.Web.Proxy.Examples.Basic.csproj
+2
-1
CertificateManager.cs
Titanium.Web.Proxy/Network/CertificateManager.cs
+28
-18
ProxyServer.cs
Titanium.Web.Proxy/ProxyServer.cs
+10
-2
Titanium.Web.Proxy.csproj
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
+2
-0
No files found.
Examples/Titanium.Web.Proxy.Examples.Basic/Titanium.Web.Proxy.Examples.Basic.csproj
View file @
1ea7f3eb
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
<Prefer32Bit>
false
</Prefer32Bit>
<Prefer32Bit>
false
</Prefer32Bit>
</PropertyGroup>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "
>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "
>
<DebugType>
pdbonly
</DebugType>
<DebugType>
none
</DebugType>
<Optimize>
true
</Optimize>
<Optimize>
true
</Optimize>
<OutputPath>
bin\Release\
</OutputPath>
<OutputPath>
bin\Release\
</OutputPath>
<DefineConstants>
TRACE;NET45
</DefineConstants>
<DefineConstants>
TRACE;NET45
</DefineConstants>
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
<WarningLevel>
4
</WarningLevel>
<WarningLevel>
4
</WarningLevel>
<TargetFrameworkVersion>
v4.5
</TargetFrameworkVersion>
<TargetFrameworkVersion>
v4.5
</TargetFrameworkVersion>
<Prefer32Bit>
false
</Prefer32Bit>
<Prefer32Bit>
false
</Prefer32Bit>
<DebugSymbols>
false
</DebugSymbols>
</PropertyGroup>
</PropertyGroup>
<PropertyGroup>
<PropertyGroup>
<StartupObject
/>
<StartupObject
/>
...
...
Titanium.Web.Proxy/Network/CertificateManager.cs
View file @
1ea7f3eb
...
@@ -177,36 +177,46 @@ namespace Titanium.Web.Proxy.Network
...
@@ -177,36 +177,46 @@ namespace Titanium.Web.Proxy.Network
}
}
}
}
internal
bool
TrustRootCertificate
()
/// <summary>
/// Make current machine trust the Root Certificate used by this proxy
/// </summary>
/// <param name="storeLocation"></param>
/// <param name="exceptionFunc"></param>
/// <returns></returns>
internal
void
TrustRootCertificate
(
StoreLocation
storeLocation
,
Action
<
Exception
>
exceptionFunc
)
{
{
if
(
rootCertificate
==
null
)
if
(
rootCertificate
==
null
)
{
{
return
false
;
exceptionFunc
(
new
Exception
(
"Could not set root certificate"
+
" as system proxy since it is null or empty."
));
return
;
}
}
X509Store
x509RootStore
=
new
X509Store
(
StoreName
.
Root
,
storeLocation
);
var
x509PersonalStore
=
new
X509Store
(
StoreName
.
My
,
storeLocation
);
try
try
{
{
X509Store
x509RootStore
=
new
X509Store
(
StoreName
.
Root
,
StoreLocation
.
CurrentUser
);
var
x509PersonalStore
=
new
X509Store
(
StoreName
.
My
,
StoreLocation
.
CurrentUser
);
x509RootStore
.
Open
(
OpenFlags
.
ReadWrite
);
x509RootStore
.
Open
(
OpenFlags
.
ReadWrite
);
x509PersonalStore
.
Open
(
OpenFlags
.
ReadWrite
);
x509PersonalStore
.
Open
(
OpenFlags
.
ReadWrite
);
try
{
x509RootStore
.
Add
(
rootCertificate
);
x509RootStore
.
Add
(
rootCertificate
);
x509PersonalStore
.
Add
(
rootCertificate
);
x509PersonalStore
.
Add
(
rootCertificate
);
}
}
catch
(
Exception
e
)
{
exceptionFunc
(
new
Exception
(
"Failed to make system trust root certificate "
+
$" for
{
storeLocation
}
store location. You may need admin rights."
,
e
));
}
finally
finally
{
{
x509RootStore
.
Close
();
x509RootStore
.
Close
();
x509PersonalStore
.
Close
();
x509PersonalStore
.
Close
();
}
}
return
true
;
}
catch
{
return
false
;
}
}
}
public
void
Dispose
()
public
void
Dispose
()
...
...
Titanium.Web.Proxy/ProxyServer.cs
View file @
1ea7f3eb
...
@@ -10,6 +10,7 @@ using Titanium.Web.Proxy.Network;
...
@@ -10,6 +10,7 @@ using Titanium.Web.Proxy.Network;
using
System.Linq
;
using
System.Linq
;
using
System.Security.Authentication
;
using
System.Security.Authentication
;
using
Titanium.Web.Proxy.Network.Tcp
;
using
Titanium.Web.Proxy.Network.Tcp
;
using
System.Security.Cryptography.X509Certificates
;
namespace
Titanium.Web.Proxy
namespace
Titanium.Web.Proxy
{
{
...
@@ -55,7 +56,8 @@ namespace Titanium.Web.Proxy
...
@@ -55,7 +56,8 @@ namespace Titanium.Web.Proxy
private
SystemProxyManager
systemProxySettingsManager
{
get
;
}
private
SystemProxyManager
systemProxySettingsManager
{
get
;
}
#if !DEBUG
#if !DEBUG
private
FireFoxProxySettingsManager
firefoxProxySettingsManager
{
get
;
set
;
}
private
FireFoxProxySettingsManager
firefoxProxySettingsManager
=
new
FireFoxProxySettingsManager
();
#endif
#endif
/// <summary>
/// <summary>
...
@@ -360,7 +362,13 @@ namespace Titanium.Web.Proxy
...
@@ -360,7 +362,13 @@ namespace Titanium.Web.Proxy
if
(
TrustRootCertificate
)
if
(
TrustRootCertificate
)
{
{
certificateCacheManager
.
TrustRootCertificate
();
//current user
certificateCacheManager
.
TrustRootCertificate
(
StoreLocation
.
CurrentUser
,
exceptionFunc
);
//current system
certificateCacheManager
.
TrustRootCertificate
(
StoreLocation
.
LocalMachine
,
exceptionFunc
);
}
}
if
(
ForwardToUpstreamGateway
&&
GetCustomUpStreamHttpProxyFunc
==
null
&&
GetCustomUpStreamHttpsProxyFunc
==
null
)
if
(
ForwardToUpstreamGateway
&&
GetCustomUpStreamHttpProxyFunc
==
null
&&
GetCustomUpStreamHttpsProxyFunc
==
null
)
...
...
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
View file @
1ea7f3eb
...
@@ -34,6 +34,8 @@
...
@@ -34,6 +34,8 @@
<DefineConstants>
NET45
</DefineConstants>
<DefineConstants>
NET45
</DefineConstants>
<Prefer32Bit>
false
</Prefer32Bit>
<Prefer32Bit>
false
</Prefer32Bit>
<DocumentationFile>
bin\Release\Titanium.Web.Proxy.XML
</DocumentationFile>
<DocumentationFile>
bin\Release\Titanium.Web.Proxy.XML
</DocumentationFile>
<DebugType>
none
</DebugType>
<DebugSymbols>
false
</DebugSymbols>
</PropertyGroup>
</PropertyGroup>
<PropertyGroup>
<PropertyGroup>
<SignAssembly>
true
</SignAssembly>
<SignAssembly>
true
</SignAssembly>
...
...
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