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
6a9e1839
Commit
6a9e1839
authored
Mar 12, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup
parent
3e3698bc
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
191 additions
and
112 deletions
+191
-112
ProxyTestController.cs
.../Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
+3
-1
CertificateManagerTests.cs
...s/Titanium.Web.Proxy.UnitTests/CertificateManagerTests.cs
+2
-2
BCCertificateMaker.cs
Titanium.Web.Proxy/Network/Certificate/BCCertificateMaker.cs
+2
-3
CertificateManager.cs
Titanium.Web.Proxy/Network/CertificateManager.cs
+177
-103
ProxyServer.cs
Titanium.Web.Proxy/ProxyServer.cs
+2
-2
ProxyConstants.cs
Titanium.Web.Proxy/Shared/ProxyConstants.cs
+5
-1
No files found.
Examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
View file @
6a9e1839
...
@@ -32,8 +32,10 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -32,8 +32,10 @@ namespace Titanium.Web.Proxy.Examples.Basic
proxyServer
=
new
ProxyServer
();
proxyServer
=
new
ProxyServer
();
//generate root certificate without storing it in file system
//generate root certificate without storing it in file system
//proxyServer.CertificateManager.CreateTrustedRootCertificate(false);
//proxyServer.CertificateManager.CreateRootCertificate(false);
//proxyServer.CertificateManager.TrustRootCertificate();
//proxyServer.CertificateManager.TrustRootCertificate();
//proxyServer.CertificateManager.TrustRootCertificateAsAdmin();
proxyServer
.
ExceptionFunc
=
exception
=>
Console
.
WriteLine
(
exception
.
Message
);
proxyServer
.
ExceptionFunc
=
exception
=>
Console
.
WriteLine
(
exception
.
Message
);
proxyServer
.
ForwardToUpstreamGateway
=
true
;
proxyServer
.
ForwardToUpstreamGateway
=
true
;
...
...
Tests/Titanium.Web.Proxy.UnitTests/CertificateManagerTests.cs
View file @
6a9e1839
...
@@ -56,7 +56,7 @@ namespace Titanium.Web.Proxy.UnitTests
...
@@ -56,7 +56,7 @@ namespace Titanium.Web.Proxy.UnitTests
mgr
.
CertificateEngine
=
CertificateEngine
.
DefaultWindows
;
mgr
.
CertificateEngine
=
CertificateEngine
.
DefaultWindows
;
mgr
.
CreateRootCertificate
(
true
);
mgr
.
CreateRootCertificate
(
true
);
mgr
.
TrustRootCertificate
();
mgr
.
TrustRootCertificate
(
true
);
mgr
.
ClearIdleCertificates
();
mgr
.
ClearIdleCertificates
();
for
(
int
i
=
0
;
i
<
5
;
i
++)
for
(
int
i
=
0
;
i
<
5
;
i
++)
...
@@ -71,7 +71,7 @@ namespace Titanium.Web.Proxy.UnitTests
...
@@ -71,7 +71,7 @@ namespace Titanium.Web.Proxy.UnitTests
}
}
await
Task
.
WhenAll
(
tasks
.
ToArray
());
await
Task
.
WhenAll
(
tasks
.
ToArray
());
mgr
.
RemoveTrustedRootCertificate
();
mgr
.
RemoveTrustedRootCertificate
(
true
);
mgr
.
StopClearIdleCertificates
();
mgr
.
StopClearIdleCertificates
();
}
}
}
}
...
...
Titanium.Web.Proxy/Network/Certificate/BCCertificateMaker.cs
View file @
6a9e1839
...
@@ -17,6 +17,7 @@ using Org.BouncyCastle.Pkcs;
...
@@ -17,6 +17,7 @@ using Org.BouncyCastle.Pkcs;
using
Org.BouncyCastle.Security
;
using
Org.BouncyCastle.Security
;
using
Org.BouncyCastle.Utilities
;
using
Org.BouncyCastle.Utilities
;
using
Org.BouncyCastle.X509
;
using
Org.BouncyCastle.X509
;
using
Titanium.Web.Proxy.Shared
;
namespace
Titanium.Web.Proxy.Network.Certificate
namespace
Titanium.Web.Proxy.Network.Certificate
{
{
...
@@ -25,8 +26,6 @@ namespace Titanium.Web.Proxy.Network.Certificate
...
@@ -25,8 +26,6 @@ namespace Titanium.Web.Proxy.Network.Certificate
/// </summary>
/// </summary>
internal
class
BCCertificateMaker
:
ICertificateMaker
internal
class
BCCertificateMaker
:
ICertificateMaker
{
{
public
static
readonly
Regex
CNRemoverRegex
=
new
Regex
(
@"^CN\s*=\s*"
,
RegexOptions
.
IgnoreCase
|
RegexOptions
.
Compiled
);
private
const
int
certificateValidDays
=
1825
;
private
const
int
certificateValidDays
=
1825
;
private
const
int
certificateGraceDays
=
366
;
private
const
int
certificateGraceDays
=
366
;
...
@@ -149,7 +148,7 @@ namespace Titanium.Web.Proxy.Network.Certificate
...
@@ -149,7 +148,7 @@ namespace Titanium.Web.Proxy.Network.Certificate
{
{
try
try
{
{
x509Certificate
.
FriendlyName
=
CNRemoverRegex
.
Replace
(
subjectName
,
string
.
Empty
);
x509Certificate
.
FriendlyName
=
ProxyConstants
.
CNRemoverRegex
.
Replace
(
subjectName
,
string
.
Empty
);
}
}
catch
(
PlatformNotSupportedException
)
catch
(
PlatformNotSupportedException
)
{
{
...
...
Titanium.Web.Proxy/Network/CertificateManager.cs
View file @
6a9e1839
This diff is collapsed.
Click to expand it.
Titanium.Web.Proxy/ProxyServer.cs
View file @
6a9e1839
...
@@ -245,8 +245,8 @@ namespace Titanium.Web.Proxy
...
@@ -245,8 +245,8 @@ namespace Titanium.Web.Proxy
}
}
CertificateManager
=
new
CertificateManager
(
ExceptionFunc
);
CertificateManager
=
new
CertificateManager
(
ExceptionFunc
);
CertificateManager
.
TrustRoot
=
trustRootCertificate
;
CertificateManager
.
User
TrustRoot
=
trustRootCertificate
;
CertificateManager
.
TrustRootAsAdministrator
=
trustRootCertificateAsAdmin
;
CertificateManager
.
Machine
TrustRootAsAdministrator
=
trustRootCertificateAsAdmin
;
if
(
rootCertificateName
!=
null
)
if
(
rootCertificateName
!=
null
)
{
{
...
...
Titanium.Web.Proxy/Shared/ProxyConstants.cs
View file @
6a9e1839
namespace
Titanium.Web.Proxy.Shared
using
System.Text.RegularExpressions
;
namespace
Titanium.Web.Proxy.Shared
{
{
/// <summary>
/// <summary>
/// Literals shared by Proxy Server
/// Literals shared by Proxy Server
...
@@ -13,5 +15,7 @@
...
@@ -13,5 +15,7 @@
internal
static
readonly
char
[]
EqualSplit
=
{
'='
};
internal
static
readonly
char
[]
EqualSplit
=
{
'='
};
internal
static
readonly
byte
[]
NewLine
=
{(
byte
)
'\r'
,
(
byte
)
'\n'
};
internal
static
readonly
byte
[]
NewLine
=
{(
byte
)
'\r'
,
(
byte
)
'\n'
};
public
static
readonly
Regex
CNRemoverRegex
=
new
Regex
(
@"^CN\s*=\s*"
,
RegexOptions
.
IgnoreCase
|
RegexOptions
.
Compiled
);
}
}
}
}
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