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
43895859
Commit
43895859
authored
Jan 24, 2017
by
Jehonathan
Committed by
GitHub
Jan 24, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #174 from justcoding121/develop
Merge Develop to Beta
parents
cd7e374e
9020e09f
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
145 additions
and
12 deletions
+145
-12
ProxyTestController.cs
.../Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
+8
-3
README.md
README.md
+8
-3
AssemblyInfo.cs
...s/Titanium.Web.Proxy.UnitTests/Properties/AssemblyInfo.cs
+0
-1
StrongNameKey.snk
Tests/Titanium.Web.Proxy.UnitTests/StrongNameKey.snk
+0
-0
Titanium.Web.Proxy.UnitTests.csproj
...m.Web.Proxy.UnitTests/Titanium.Web.Proxy.UnitTests.csproj
+9
-0
SessionEventArgs.cs
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
+70
-3
GenericResponse.cs
Titanium.Web.Proxy/Http/Responses/GenericResponse.cs
+22
-0
EndPoint.cs
Titanium.Web.Proxy/Models/EndPoint.cs
+3
-0
AssemblyInfo.cs
Titanium.Web.Proxy/Properties/AssemblyInfo.cs
+6
-1
RequestHandler.cs
Titanium.Web.Proxy/RequestHandler.cs
+11
-1
StrongNameKey.snk
Titanium.Web.Proxy/StrongNameKey.snk
+0
-0
Titanium.Web.Proxy.csproj
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
+8
-0
No files found.
Examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
View file @
43895859
...
...
@@ -28,12 +28,17 @@ namespace Titanium.Web.Proxy.Examples.Basic
proxyServer
.
ServerCertificateValidationCallback
+=
OnCertificateValidation
;
proxyServer
.
ClientCertificateSelectionCallback
+=
OnCertificateSelection
;
var
explicitEndPoint
=
new
ExplicitProxyEndPoint
(
IPAddress
.
Any
,
8000
,
true
)
{
//Exclude Https addresses you don't want to proxy
//Usefull for clients that use certificate pinning
//for example dropbox.com
var
explicitEndPoint
=
new
ExplicitProxyEndPoint
(
IPAddress
.
Any
,
8000
,
true
)
{
// ExcludedHttpsHostNameRegex = new List<string>() { "google.com", "dropbox.com" }
//Use self-issued generic certificate on all https requests
//Optimizes performance by not creating a certificate for each https-enabled domain
//Usefull when certificate trust is not requiered by proxy clients
// GenericCertificate = new X509Certificate2(Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "genericcert.pfx"), "password")
};
//An explicit endpoint is where the client knows about the existance of a proxy
...
...
README.md
View file @
43895859
...
...
@@ -49,12 +49,17 @@ Setup HTTP proxy:
proxyServer
.
ClientCertificateSelectionCallback
+=
OnCertificateSelection
;
var
explicitEndPoint
=
new
ExplicitProxyEndPoint
(
IPAddress
.
Any
,
8000
,
true
)
{
//Exclude Https addresses you don't want to proxy
//Usefull for clients that use certificate pinning
//for example dropbox.com
var
explicitEndPoint
=
new
ExplicitProxyEndPoint
(
IPAddress
.
Any
,
8000
,
true
)
{
// ExcludedHttpsHostNameRegex = new List<string>() { "google.com", "dropbox.com" }
//Use self-issued generic certificate on all https requests
//Optimizes performance by not creating a certificate for each https-enabled domain
//Usefull when certificate trust is not requiered by proxy clients
// GenericCertificate = new X509Certificate2(Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "genericcert.pfx"), "password")
};
//An explicit endpoint is where the client knows about the existance of a proxy
...
...
Tests/Titanium.Web.Proxy.UnitTests/Properties/AssemblyInfo.cs
View file @
43895859
using
System.Reflection
;
using
System.Runtime.CompilerServices
;
using
System.Runtime.InteropServices
;
// General Information about an assembly is controlled through the following
...
...
Tests/Titanium.Web.Proxy.UnitTests/StrongNameKey.snk
0 → 100644
View file @
43895859
File added
Tests/Titanium.Web.Proxy.UnitTests/Titanium.Web.Proxy.UnitTests.csproj
View file @
43895859
...
...
@@ -34,6 +34,12 @@
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>
true
</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>
StrongNameKey.snk
</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"System"
/>
</ItemGroup>
...
...
@@ -60,6 +66,9 @@
<Name>
Titanium.Web.Proxy
</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None
Include=
"StrongNameKey.snk"
/>
</ItemGroup>
<Choose>
<When
Condition=
"'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'"
>
<ItemGroup>
...
...
Titanium.Web.Proxy/EventArguments/SessionEventArgs.cs
View file @
43895859
...
...
@@ -405,7 +405,8 @@ namespace Titanium.Web.Proxy.EventArguments
/// <param name="headers"></param>
public
async
Task
Ok
(
byte
[]
result
,
Dictionary
<
string
,
HttpHeader
>
headers
)
{
var
response
=
new
OkResponse
();
var
response
=
new
OkResponse
();
if
(
headers
!=
null
&&
headers
.
Count
>
0
)
{
response
.
ResponseHeaders
=
headers
;
...
...
@@ -418,6 +419,72 @@ namespace Titanium.Web.Proxy.EventArguments
WebSession
.
Request
.
CancelRequest
=
true
;
}
/// <summary>
/// Before request is made to server
/// Respond with the specified HTML string to client
/// and ignore the request
/// </summary>
/// <param name="html"></param>
/// <param name="status"></param>
public
async
Task
GenericResponse
(
string
html
,
HttpStatusCode
status
)
{
await
GenericResponse
(
html
,
null
,
status
);
}
/// <summary>
/// Before request is made to server
/// Respond with the specified HTML string to client
/// and the specified status
/// and ignore the request
/// </summary>
/// <param name="html"></param>
/// <param name="headers"></param>
/// <param name="status"></param>
public
async
Task
GenericResponse
(
string
html
,
Dictionary
<
string
,
HttpHeader
>
headers
,
HttpStatusCode
status
)
{
if
(
WebSession
.
Request
.
RequestLocked
)
{
throw
new
Exception
(
"You cannot call this function after request is made to server."
);
}
if
(
html
==
null
)
{
html
=
string
.
Empty
;
}
var
result
=
Encoding
.
Default
.
GetBytes
(
html
);
await
GenericResponse
(
result
,
headers
,
status
);
}
/// <summary>
/// Before request is made to server
/// Respond with the specified byte[] to client
/// and the specified status
/// and ignore the request
/// </summary>
/// <param name="result"></param>
/// <param name="headers"></param>
/// <param name="status"></param>
/// <returns></returns>
public
async
Task
GenericResponse
(
byte
[]
result
,
Dictionary
<
string
,
HttpHeader
>
headers
,
HttpStatusCode
status
)
{
var
response
=
new
GenericResponse
(
status
);
if
(
headers
!=
null
&&
headers
.
Count
>
0
)
{
response
.
ResponseHeaders
=
headers
;
}
response
.
HttpVersion
=
WebSession
.
Request
.
HttpVersion
;
response
.
ResponseBody
=
result
;
await
Respond
(
response
);
WebSession
.
Request
.
CancelRequest
=
true
;
}
public
async
Task
Redirect
(
string
url
)
{
var
response
=
new
RedirectResponse
();
...
...
Titanium.Web.Proxy/Http/Responses/GenericResponse.cs
0 → 100644
View file @
43895859
using
System.Net
;
namespace
Titanium.Web.Proxy.Http.Responses
{
/// <summary>
/// Anything other than a 200 or 302 response
/// </summary>
public
class
GenericResponse
:
Response
{
public
GenericResponse
(
HttpStatusCode
status
)
{
ResponseStatusCode
=
((
int
)
status
).
ToString
();
ResponseStatusDescription
=
status
.
ToString
();
}
public
GenericResponse
(
string
statusCode
,
string
statusDescription
)
{
ResponseStatusCode
=
statusCode
;
ResponseStatusDescription
=
statusCode
;
}
}
}
Titanium.Web.Proxy/Models/EndPoint.cs
View file @
43895859
using
System.Collections.Generic
;
using
System.Net
;
using
System.Net.Sockets
;
using
System.Security.Cryptography.X509Certificates
;
namespace
Titanium.Web.Proxy.Models
{
...
...
@@ -38,6 +39,8 @@ namespace Titanium.Web.Proxy.Models
public
List
<
string
>
ExcludedHttpsHostNameRegex
{
get
;
set
;
}
public
X509Certificate2
GenericCertificate
{
get
;
set
;
}
public
ExplicitProxyEndPoint
(
IPAddress
IpAddress
,
int
Port
,
bool
EnableSsl
)
:
base
(
IpAddress
,
Port
,
EnableSsl
)
{
...
...
Titanium.Web.Proxy/Properties/AssemblyInfo.cs
View file @
43895859
...
...
@@ -14,7 +14,12 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: InternalsVisibleTo("Titanium.Web.Proxy.UnitTests")]
[
assembly
:
InternalsVisibleTo
(
"Titanium.Web.Proxy.UnitTests, PublicKey="
+
"0024000004800000940000000602000000240000525341310004000001000100e7368e0ccc717e"
+
"eb4d57d35ad6a8305cbbed14faa222e13869405e92c83856266d400887d857005f1393ffca2b92"
+
"de7f3ba0bdad35ec2d6057ee1846091b34be2abc3f97dc7e72c16fd4958c15126b12923df76964"
+
"7d84922c3f4f3b80ee0ae8e4cb40bc1973b782afb90bb00519fd16adf960f217e23696e7c31654"
+
"01d0acd6"
)]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
...
...
Titanium.Web.Proxy/RequestHandler.cs
View file @
43895859
...
...
@@ -113,7 +113,17 @@ namespace Titanium.Web.Proxy
{
sslStream
=
new
SslStream
(
clientStream
,
true
);
var
certificate
=
certificateCacheManager
.
CreateCertificate
(
httpRemoteUri
.
Host
,
false
);
X509Certificate2
certificate
;
if
(
endPoint
.
GenericCertificate
!=
null
)
{
certificate
=
endPoint
.
GenericCertificate
;
}
else
{
certificate
=
certificateCacheManager
.
CreateCertificate
(
httpRemoteUri
.
Host
,
false
);
}
//Successfully managed to authenticate the client using the fake certificate
await
sslStream
.
AuthenticateAsServerAsync
(
certificate
,
false
,
SupportedSslProtocols
,
false
);
...
...
Titanium.Web.Proxy/StrongNameKey.snk
0 → 100644
View file @
43895859
File added
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
View file @
43895859
...
...
@@ -35,6 +35,12 @@
<Prefer32Bit>
false
</Prefer32Bit>
<DocumentationFile>
bin\Release\Titanium.Web.Proxy.XML
</DocumentationFile>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>
true
</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>
StrongNameKey.snk
</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"Ionic.Zip, Version=1.9.8.0, Culture=neutral, PublicKeyToken=6583c7c814667745, processorArchitecture=MSIL"
>
<HintPath>
..\packages\DotNetZip.1.9.8\lib\net20\Ionic.Zip.dll
</HintPath>
...
...
@@ -67,6 +73,7 @@
<Compile
Include=
"EventArguments\CertificateValidationEventArgs.cs"
/>
<Compile
Include=
"Extensions\ByteArrayExtensions.cs"
/>
<Compile
Include=
"Helpers\Network.cs"
/>
<Compile
Include=
"Http\Responses\GenericResponse.cs"
/>
<Compile
Include=
"Network\CachedCertificate.cs"
/>
<Compile
Include=
"Network\CertificateMaker.cs"
/>
<Compile
Include=
"Network\ProxyClient.cs"
/>
...
...
@@ -117,6 +124,7 @@
<ItemGroup>
<None
Include=
"app.config"
/>
<None
Include=
"packages.config"
/>
<None
Include=
"StrongNameKey.snk"
/>
</ItemGroup>
<Import
Project=
"$(MSBuildToolsPath)\Microsoft.CSharp.targets"
/>
<Import
Project=
"$(SolutionDir)\.nuget\NuGet.targets"
Condition=
"Exists('$(SolutionDir)\.nuget\NuGet.targets')"
/>
...
...
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