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
7f5b5d52
Unverified
Commit
7f5b5d52
authored
Feb 23, 2018
by
mohammadlachgar
Committed by
GitHub
Feb 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new properties
Like : *overwritePFXfile *passwordpfx *namePFXfile *saveFakeCertificates
parent
cc18c33e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
45 deletions
+67
-45
ProxyServer.cs
Titanium.Web.Proxy/ProxyServer.cs
+67
-45
No files found.
Titanium.Web.Proxy/ProxyServer.cs
View file @
7f5b5d52
...
@@ -40,27 +40,30 @@ namespace Titanium.Web.Proxy
...
@@ -40,27 +40,30 @@ namespace Titanium.Web.Proxy
/// <summary>
/// <summary>
/// Backing field for corresponding public property
/// Backing field for corresponding public property
/// </summary>
/// </summary>
private
bool
trustRootCertificate
;
private
int
clientConnectionCount
;
private
bool
saveCertificate
=
false
;
/// <summary>
/// <summary>
///
Password for export and load rootCert.pfx
///
Backing field for corresponding public property
/// </summary>
/// </summary>
private
string
password_rootCert
=
string
.
Empty
;
private
int
serverConnectionCount
;
/// <summary>
/// <summary>
/// Backing field for corresponding public property
/// Backing field for corresponding public property
/// </summary>
/// </summary>
private
int
clientConnectionCount
;
private
bool
trustRootCertificate
=
false
;
private
bool
overwritePFXfile
=
true
;
/// <summary>
/// <summary>
///
Backing field for corresponding public property
///
Password for export and load rootCert.pfx
/// </summary>
/// </summary>
private
int
serverConnectionCount
;
private
string
passwordPFX
=
string
.
Empty
;
private
string
namePFXfile
=
string
.
Empty
;
private
X509KeyStorageFlags
storageFlag
=
X509KeyStorageFlags
.
Exportable
;
private
bool
saveFakeCertificates
=
false
;
/// <summary>
/// <summary>
/// A object that creates tcp connection to server
/// A object that creates tcp connection to server
...
@@ -132,45 +135,75 @@ namespace Titanium.Web.Proxy
...
@@ -132,45 +135,75 @@ namespace Titanium.Web.Proxy
set
set
{
{
trustRootCertificate
=
value
;
trustRootCertificate
=
value
;
CertificateManager
.
TrustrootCertificate
=
trustRootCertificate
;
CertificateManager
.
trustRootCertificate
=
trustRootCertificate
;
//if (value)
//{
////convert to public function
///now, "Manually" call this function===> EnsureRootCertificate();
//
//}
}
}
}
}
/// <summary>
/// <summary>
/// Save all fake certificates in folder "crts"(will be
save
in proxy dll directory)
/// Save all fake certificates in folder "crts"(will be
created
in proxy dll directory)
///
for can load the certificate and not make new certificate every time
///
<para>for can load the certificate and not make new certificate every time </para>
/// </summary>
/// </summary>
public
bool
SaveFakeCertificates
public
bool
SaveFakeCertificates
{
{
get
=>
save
Certificate
;
get
=>
save
FakeCertificates
;
set
set
{
{
save
Certificate
=
value
;
save
FakeCertificates
=
value
;
CertificateManager
.
SaveCertificate
=
saveCertificate
;
CertificateManager
.
saveFakeCertificates
=
saveFakeCertificates
;
}
}
}
}
/// <summary>
/// Overwrite Root certificate file
/// <para>true : replace an existing .pfx file if password is incorect or if RootCertificate = null</para>
/// </summary>
public
bool
OverwritePFXfile
{
get
=>
overwritePFXfile
;
set
{
overwritePFXfile
=
value
;
CertificateManager
.
overwritePFXfile
=
this
.
overwritePFXfile
;
}
}
/// <summary>
/// <summary>
/// add password to rootCert.pfx
/// Password of the Root certificate file
/// <para>Set a password for the .pfx file</para>
/// </summary>
/// </summary>
public
string
Password
_rootCert
public
string
Password
PFX
{
{
get
=>
this
.
password_rootCert
;
get
=>
passwordPFX
;
set
set
{
{
this
.
password_rootCert
=
value
;
passwordPFX
=
value
;
CertificateManager
.
Password_rootCert
=
this
.
password_rootCert
;
CertificateManager
.
passwordpfx
=
this
.
passwordPFX
;
}
}
/// <summary>
/// Name(path) of the Root certificate file
/// <para>Set the name(path) of the .pfx file. If it is string.Empty Root certificate file will be named as "rootCert.pfx" (and will be saved in proxy dll directory)</para>
/// </summary>
public
string
NamePFXfile
{
get
=>
namePFXfile
;
set
{
namePFXfile
=
value
;
CertificateManager
.
namePFXfile
=
this
.
namePFXfile
;
}
}
}
}
public
X509KeyStorageFlags
StorageFlag
{
get
=>
storageFlag
;
set
{
storageFlag
=
value
;
CertificateManager
.
storageFlag
=
this
.
storageFlag
;
}
}
/// <summary>
/// <summary>
/// Select Certificate Engine
/// Select Certificate Engine
...
@@ -417,7 +450,6 @@ namespace Titanium.Web.Proxy
...
@@ -417,7 +450,6 @@ namespace Titanium.Web.Proxy
SetAsSystemProxy
(
endPoint
,
ProxyProtocolType
.
Http
);
SetAsSystemProxy
(
endPoint
,
ProxyProtocolType
.
Http
);
}
}
/// <summary>
/// <summary>
/// Set the given explicit end point as the default proxy server for current machine
/// Set the given explicit end point as the default proxy server for current machine
/// </summary>
/// </summary>
...
@@ -563,17 +595,10 @@ namespace Titanium.Web.Proxy
...
@@ -563,17 +595,10 @@ namespace Titanium.Web.Proxy
throw
new
Exception
(
"Proxy is already running."
);
throw
new
Exception
(
"Proxy is already running."
);
}
}
try
{
if
(
ProxyEndPoints
.
OfType
<
ExplicitProxyEndPoint
>().
Any
(
x
=>
x
.
GenericCertificate
==
null
))
if
(
ProxyEndPoints
.
OfType
<
ExplicitProxyEndPoint
>().
Any
(
x
=>
x
.
GenericCertificate
==
null
))
{
{
EnsureRootCertificate
();
EnsureRootCertificate
();
}
}
}
catch
(
Exception
ex
)
{
throw
new
Exception
(
ex
.
Message
);
}
//clear any system proxy settings which is pointing to our own endpoint (causing a cycle)
//clear any system proxy settings which is pointing to our own endpoint (causing a cycle)
//due to non gracious proxy shutdown before or something else
//due to non gracious proxy shutdown before or something else
...
@@ -626,7 +651,6 @@ namespace Titanium.Web.Proxy
...
@@ -626,7 +651,6 @@ namespace Titanium.Web.Proxy
}
}
}
}
/// <summary>
/// <summary>
/// Stop this proxy server
/// Stop this proxy server
/// </summary>
/// </summary>
...
@@ -771,8 +795,6 @@ namespace Titanium.Web.Proxy
...
@@ -771,8 +795,6 @@ namespace Titanium.Web.Proxy
}
}
}
}
/// <summary>
/// <summary>
/// When a connection is received from client act
/// When a connection is received from client act
/// </summary>
/// </summary>
...
...
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