Commit 4eee7a53 authored by justcoding121's avatar justcoding121 Committed by justcoding121

#4 Pull in Nekopanda changes

Pull user:Nekopanda changes; Also moved system proxy, certificate
helpers to Proxy core project
parent 205ed9a0
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/
# Visual Studio 2015 cache/options directory
.vs/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# Windows Azure Build Output
csx/
*.build.csdef
# Windows Store app package directory
AppPackages/
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
\ No newline at end of file
......@@ -6,55 +6,49 @@ using System.Reflection;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using Titanium.Web.Proxy.Test.Helpers;
using Titanium.Web.Proxy.Helpers;
namespace Titanium.Web.Proxy.Test
{
public class Program
{
static ProxyTestController controller = new ProxyTestController();
public static void Main(string[] args)
{
//On Console exit reset system proxy
//On Console exit make sure we also exit the proxy
handler = new ConsoleEventDelegate(ConsoleEventCallback);
SetConsoleCtrlHandler(handler, true);
//Start proxy controller
var controller = new ProxyTestController();
controller.Visited += PageVisited;
controller.StartProxy();
Console.Write("Do you want to monitor HTTPS? (Y/N):");
if(Console.ReadLine().Trim().ToLower()=="y" )
{
InstallCertificate(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));
SystemProxyHelper.EnableProxyHTTPS("localhost", controller.ListeningPort);
controller.EnableSSL = true;
}
Console.Write("Do you want to set this as a System Proxy? (Y/N):");
if (Console.ReadLine().Trim().ToLower() == "y")
{
controller.SetAsSystemProxy = true;
}
controller.Visited += PageVisited;
//Start proxy controller
controller.StartProxy();
Console.WriteLine("Hit any key to exit..");
Console.WriteLine();
Console.Read();
//Reset System Proxy on exit
SystemProxyHelper.DisableAllProxy();
FireFoxHelper.RemoveFirefox();
controller.Stop();
}
private static void InstallCertificate(string CertificateDirectory)
{
X509Certificate2 certificate = new X509Certificate2(Path.Combine(CertificateDirectory , "Titanium Proxy Test Root Certificate.cer"));
X509Store store = new X509Store(StoreName.Root, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadWrite);
store.Add(certificate);
store.Close();
X509Store store1 = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store1.Open(OpenFlags.ReadWrite);
store1.Add(certificate);
store1.Close();
}
private static void PageVisited(VisitedEventArgs e)
{
Console.WriteLine(string.Concat("Visited: ", e.URL));
......@@ -65,8 +59,7 @@ namespace Titanium.Web.Proxy.Test
{
try
{
SystemProxyHelper.DisableAllProxy();
FireFoxHelper.RemoveFirefox();
controller.Stop();
}
catch { }
......
......@@ -8,7 +8,7 @@ using System.DirectoryServices.AccountManagement;
using System.DirectoryServices.ActiveDirectory;
using Titanium.Web.Proxy.Models;
using Titanium.Web.Proxy;
using Titanium.Web.Proxy.Test.Helpers;
using Titanium.Web.Proxy.Helpers;
......@@ -20,6 +20,8 @@ namespace Titanium.Web.Proxy.Test
private string _lastURL = string.Empty;
public int ListeningPort { get; set; }
public bool EnableSSL { get; set; }
public bool SetAsSystemProxy { get; set; }
public void StartProxy()
{
......@@ -29,12 +31,14 @@ namespace Titanium.Web.Proxy.Test
ProxyServer.BeforeRequest += OnRequest;
ProxyServer.BeforeResponse += OnResponse;
}
ProxyServer.Start();
ProxyServer.EnableSSL = EnableSSL;
ProxyServer.SetAsSystemProxy = SetAsSystemProxy;
SystemProxyHelper.EnableProxyHTTP("localhost", ProxyServer.ListeningPort);
FireFoxHelper.AddFirefox();
ProxyServer.Start();
ListeningPort = ProxyServer.ListeningPort;
......@@ -167,6 +171,8 @@ namespace Titanium.Web.Proxy.Test
return builder.ToString();
}
}
public class VisitedEventArgs : EventArgs
{
......
......@@ -54,20 +54,12 @@
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ProxyTestController.cs" />
<Compile Include="Helpers\Firefox.cs" />
<Compile Include="Helpers\SystemProxy.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Capture.PNG" />
<Content Include="makecert.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="Titanium Proxy Test Root Certificate.cer">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Titanium.Web.Proxy\Titanium.Web.Proxy.csproj">
......
......@@ -17,5 +17,7 @@
<files>
<file src="Titanium.Web.Proxy\bin\$configuration$\Titanium.Web.Proxy.dll" target="lib\net40\" />
<file src="Titanium.Web.Proxy\bin\$configuration$\Ionic.Zip.dll" target="lib\net40\" />
<file src="Titanium.Web.Proxy\bin\$configuration$\makecert.exe" />
<file src="Titanium.Web.Proxy\bin\$configuration$\DO_NOT_TRUST_FiddlerRoot.cer" />
</files>
</package>
\ No newline at end of file
......@@ -5,10 +5,10 @@ VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{B6DBABDC-C985-4872-9C38-B4E5079CBC4B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Titanium.Web.Proxy", "Titanium.Web.Proxy\Titanium.Web.Proxy.csproj", "{8D73A1BE-868C-42D2-9ECE-F32CC1A02906}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Titanium.Web.Proxy.Test", "Titanium.Web.Proxy.Test\Titanium.Web.Proxy.Test.csproj", "{F3B7E553-1904-4E80-BDC7-212342B5C952}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Titanium.Web.Proxy", "Titanium.Web.Proxy\Titanium.Web.Proxy.csproj", "{8D73A1BE-868C-42D2-9ECE-F32CC1A02906}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -19,6 +19,14 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F3B7E553-1904-4E80-BDC7-212342B5C952}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F3B7E553-1904-4E80-BDC7-212342B5C952}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F3B7E553-1904-4E80-BDC7-212342B5C952}.Debug|x64.ActiveCfg = Debug|Any CPU
{F3B7E553-1904-4E80-BDC7-212342B5C952}.Debug|x86.ActiveCfg = Debug|Any CPU
{F3B7E553-1904-4E80-BDC7-212342B5C952}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F3B7E553-1904-4E80-BDC7-212342B5C952}.Release|Any CPU.Build.0 = Release|Any CPU
{F3B7E553-1904-4E80-BDC7-212342B5C952}.Release|x64.ActiveCfg = Release|Any CPU
{F3B7E553-1904-4E80-BDC7-212342B5C952}.Release|x86.ActiveCfg = Release|Any CPU
{8D73A1BE-868C-42D2-9ECE-F32CC1A02906}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8D73A1BE-868C-42D2-9ECE-F32CC1A02906}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8D73A1BE-868C-42D2-9ECE-F32CC1A02906}.Debug|x64.ActiveCfg = Debug|x64
......@@ -31,14 +39,6 @@ Global
{8D73A1BE-868C-42D2-9ECE-F32CC1A02906}.Release|x64.Build.0 = Release|x64
{8D73A1BE-868C-42D2-9ECE-F32CC1A02906}.Release|x86.ActiveCfg = Release|x86
{8D73A1BE-868C-42D2-9ECE-F32CC1A02906}.Release|x86.Build.0 = Release|x86
{F3B7E553-1904-4E80-BDC7-212342B5C952}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F3B7E553-1904-4E80-BDC7-212342B5C952}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F3B7E553-1904-4E80-BDC7-212342B5C952}.Debug|x64.ActiveCfg = Debug|Any CPU
{F3B7E553-1904-4E80-BDC7-212342B5C952}.Debug|x86.ActiveCfg = Debug|Any CPU
{F3B7E553-1904-4E80-BDC7-212342B5C952}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F3B7E553-1904-4E80-BDC7-212342B5C952}.Release|Any CPU.Build.0 = Release|Any CPU
{F3B7E553-1904-4E80-BDC7-212342B5C952}.Release|x64.ActiveCfg = Release|Any CPU
{F3B7E553-1904-4E80-BDC7-212342B5C952}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -3,12 +3,13 @@ using System.Security.Cryptography.X509Certificates;
using System.Diagnostics;
using System.Threading;
namespace Titanium.Web.Proxy.Helpers
{
public class CertificateHelper
{
private static X509Store store;
public static X509Certificate2 GetCertificate(string Hostname)
public static X509Certificate2 GetCertificate(string RootCertificateName, string Hostname)
{
if (store == null)
......@@ -16,29 +17,29 @@ namespace Titanium.Web.Proxy.Helpers
store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
}
var CachedCertificate = GetCertifiateFromStore(Hostname);
var CachedCertificate = GetCertifiateFromStore(RootCertificateName, Hostname);
if (CachedCertificate == null)
CreateClientCertificate(Hostname);
CreateClientCertificate(RootCertificateName, Hostname);
return GetCertifiateFromStore(Hostname);
return GetCertifiateFromStore(RootCertificateName, Hostname);
}
private static X509Certificate2 GetCertifiateFromStore(string Hostname)
private static X509Certificate2 GetCertifiateFromStore(string RootCertificateName, string Hostname)
{
X509Certificate2Collection certificateCollection = store.Certificates.Find(X509FindType.FindBySubjectName, Hostname, true);
foreach (var certificate in certificateCollection)
{
if (certificate.SubjectName.Name.StartsWith("CN=" + Hostname) && certificate.IssuerName.Name.StartsWith("CN=Titanium_Proxy_Test_Root"))
if (certificate.SubjectName.Name.StartsWith("CN=" + Hostname) && certificate.IssuerName.Name.StartsWith("CN=" + RootCertificateName))
return certificate;
}
return null;
}
private static void CreateClientCertificate(string Hostname)
private static void CreateClientCertificate(string RootCertificateName, string Hostname)
{
Process process = new Process();
......@@ -50,7 +51,7 @@ namespace Titanium.Web.Proxy.Helpers
// Setup executable and parameters
process.StartInfo.FileName = @"makecert.exe";
process.StartInfo.Arguments = @"-pe -ss my -n ""CN=" + Hostname + @""" -sky exchange -in Titanium_Proxy_Test_Root -is my -eku 1.3.6.1.5.5.7.3.1 -cy end -a sha1 -m 132 -b 10/07/2012";
process.StartInfo.Arguments = @" -pe -ss my -n ""CN=" + Hostname + @", O=DO_NOT_TRUST, OU=Created by http://www.fiddler2.com"" -sky exchange -in " + RootCertificateName + " -is my -eku 1.3.6.1.5.5.7.3.1 -cy end -a sha1 -m 132 -b 06/26/2014";
// Go
process.Start();
......@@ -59,5 +60,21 @@ namespace Titanium.Web.Proxy.Helpers
}
public static void InstallCertificate(string certificatePath)
{
X509Certificate2 certificate = new X509Certificate2(certificatePath);
X509Store store = new X509Store(StoreName.Root, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadWrite);
store.Add(certificate);
store.Close();
X509Store store1 = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store1.Open(OpenFlags.ReadWrite);
store1.Add(certificate);
store1.Close();
}
}
}
......@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.IO;
namespace Titanium.Web.Proxy.Test.Helpers
namespace Titanium.Web.Proxy.Helpers
{
public class FireFoxHelper
{
......
......@@ -5,7 +5,7 @@ using System.Text;
using Microsoft.Win32;
using System.Runtime.InteropServices;
namespace Titanium.Web.Proxy.Test.Helpers
namespace Titanium.Web.Proxy.Helpers
{
public static class SystemProxyHelper
{
......
......@@ -9,13 +9,13 @@ using System.Threading.Tasks;
namespace Titanium.Web.Proxy.Helpers
{
public class TcpHelper
public class TcpHelper
{
private static readonly int BUFFER_SIZE = 8192;
private static readonly String[] colonSpaceSplit = new string[] { ": " };
public static void SendRaw(string Hostname, int TunnelPort, System.IO.Stream ClientStream)
private static readonly int BUFFER_SIZE = 8192;
private static readonly String[] colonSpaceSplit = new string[] { ": " };
public static void SendRaw(string Hostname, int TunnelPort, System.IO.Stream ClientStream)
{
System.Net.Sockets.TcpClient tunnelClient = new System.Net.Sockets.TcpClient(Hostname, TunnelPort);
var tunnelStream = tunnelClient.GetStream();
......@@ -27,7 +27,7 @@ namespace Titanium.Web.Proxy.Helpers
sendRelay.Start();
receiveRelay.Start();
Task.WaitAll(sendRelay, receiveRelay);
Task.WaitAll(sendRelay, receiveRelay);
if (tunnelStream != null)
tunnelStream.Close();
......@@ -35,14 +35,14 @@ namespace Titanium.Web.Proxy.Helpers
if (tunnelClient != null)
tunnelClient.Close();
}
public static void SendRaw(string HttpCmd, string SecureHostName, ref List<string> RequestLines, bool IsHttps, Stream ClientStream)
public static void SendRaw(string HttpCmd, string SecureHostName, ref List<string> RequestLines, bool IsHttps, Stream ClientStream)
{
StringBuilder sb = new StringBuilder();
sb.Append(HttpCmd);
sb.Append(Environment.NewLine);
string hostname= SecureHostName;
for(int i = 1; i < RequestLines.Count;i++)
string hostname = SecureHostName;
for (int i = 1; i < RequestLines.Count; i++)
{
var header = RequestLines[i];
......@@ -64,14 +64,14 @@ namespace Titanium.Web.Proxy.Helpers
}
}
sb.Append(header);
sb.Append(Environment.NewLine);
sb.Append(Environment.NewLine);
}
sb.Append(Environment.NewLine);
sb.Append(Environment.NewLine);
int tunnelPort = 80;
if (IsHttps)
{
tunnelPort = 443;
}
......@@ -86,14 +86,14 @@ namespace Titanium.Web.Proxy.Helpers
tunnelStream = sslStream;
}
var sendRelay = new Task(() => StreamHelper.CopyTo(sb.ToString(), ClientStream, tunnelStream, BUFFER_SIZE));
var receiveRelay = new Task(() => StreamHelper.CopyTo(tunnelStream, ClientStream, BUFFER_SIZE));
sendRelay.Start();
receiveRelay.Start();
Task.WaitAll(sendRelay, receiveRelay);
Task.WaitAll(sendRelay, receiveRelay);
if (tunnelStream != null)
tunnelStream.Close();
......@@ -102,4 +102,4 @@ namespace Titanium.Web.Proxy.Helpers
tunnelClient.Close();
}
}
}
}
\ No newline at end of file
......@@ -121,4 +121,4 @@ namespace Titanium.Web.Proxy.Models
public IPAddress ipAddress { get; set; }
}
}
}
\ No newline at end of file
......@@ -43,8 +43,9 @@ namespace Titanium.Web.Proxy
public IPAddress ListeningIPInterface { get; set; }
public static IPAddress ListeningIPInterface { get; set; }
public static string RootCertificateName { get; set; }
public static Int32 ListeningPort
{
......@@ -78,6 +79,7 @@ namespace Titanium.Web.Proxy
private static bool ShouldListen { get; set; }
public static bool Start()
{
listener = new TcpListener(IPAddress.Any, 0);
listener.Start();
listenerThread = new Thread(new ParameterizedThreadStart(Listen));
......@@ -85,16 +87,37 @@ namespace Titanium.Web.Proxy
ShouldListen = true;
listenerThread.Start(listener);
if (SetAsSystemProxy)
{
SystemProxyHelper.EnableProxyHTTP("localhost", ListeningPort);
FireFoxHelper.AddFirefox();
RootCertificateName = RootCertificateName == null ? "DO_NOT_TRUST_FiddlerRoot" : RootCertificateName;
CertificateHelper.InstallCertificate(Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), string.Concat(RootCertificateName, ".cer")));
if (EnableSSL)
{
SystemProxyHelper.EnableProxyHTTPS("localhost", ListeningPort);
}
}
return true;
}
public static void Stop()
{
if (SetAsSystemProxy)
{
SystemProxyHelper.DisableAllProxy();
FireFoxHelper.RemoveFirefox();
}
ShouldListen = false;
listener.Stop();
listenerThread.Interrupt();
}
private static void Listen(Object obj)
......@@ -125,19 +148,23 @@ namespace Titanium.Web.Proxy
}
public static void AcceptTcpClientCallback(IAsyncResult ar)
{
// Get the listener that handles the client request.
TcpListener listener = (TcpListener)ar.AsyncState;
TcpClient client = null;
try
{
// Get the listener that handles the client request.
TcpListener listener = (TcpListener)ar.AsyncState;
TcpClient client = null;
// End the operation and display the received data on
// the console.
client = listener.EndAcceptTcpClient(ar);
// End the operation and display the received data on
// the console.
client = listener.EndAcceptTcpClient(ar);
Task.Factory.StartNew(() => ProcessClient(client));
Task.Factory.StartNew(() => ProcessClient(client));
// Signal the calling thread to continue.
tcpClientConnected.Set();
// Signal the calling thread to continue.
tcpClientConnected.Set();
}
catch(ObjectDisposedException) { }
}
private static void ProcessClient(Object param)
......@@ -157,5 +184,9 @@ namespace Titanium.Web.Proxy
}
public static bool EnableSSL { get; set; }
public static bool SetAsSystemProxy { get; set; }
}
}
}
\ No newline at end of file
......@@ -20,7 +20,7 @@ namespace Titanium.Web.Proxy
partial class ProxyServer
{
private static void HandleClientRequest(TcpClient Client)
{
......@@ -82,20 +82,20 @@ namespace Titanium.Web.Proxy
int.TryParse(splitBuffer[1].Split(':')[1], out tunnelPort);
if (tunnelPort == 0) tunnelPort = 80;
var isSecure = true;
for(int i=1;i<requestLines.Count;i++)
for (int i = 1; i < requestLines.Count; i++)
{
var rawHeader = requestLines[i];
String[] header = rawHeader.ToLower().Trim().Split(colonSpaceSplit, 2, StringSplitOptions.None);
var rawHeader = requestLines[i];
String[] header = rawHeader.ToLower().Trim().Split(colonSpaceSplit, 2, StringSplitOptions.None);
if ((header[0] == "host") )
if ((header[0] == "host"))
{
var hostDetails = header[1].ToLower().Trim().Split(':');
if (hostDetails.Length > 1)
{
var hostDetails = header[1].ToLower().Trim().Split(':');
if(hostDetails.Length>1)
{
isSecure = false;
}
isSecure = false;
}
}
}
requestLines.Clear();
......@@ -106,7 +106,7 @@ namespace Titanium.Web.Proxy
connectStreamWriter.WriteLine();
connectStreamWriter.Flush();
if (tunnelPort != 443)
{
......@@ -120,11 +120,11 @@ namespace Titanium.Web.Proxy
return;
}
Monitor.Enter(certificateAccessLock);
var _certificate = CertificateHelper.GetCertificate(tunnelHostName);
var _certificate = CertificateHelper.GetCertificate(RootCertificateName, tunnelHostName);
Monitor.Exit(certificateAccessLock);
SslStream sslStream = null;
if (!pinnedCertificateClients.Contains(tunnelHostName)&&isSecure)
if (!pinnedCertificateClients.Contains(tunnelHostName) && isSecure)
{
sslStream = new SslStream(clientStream, true);
try
......@@ -134,18 +134,18 @@ namespace Titanium.Web.Proxy
catch (AuthenticationException ex)
{
if (pinnedCertificateClients.Contains(tunnelHostName) == false)
{
pinnedCertificateClients.Add(tunnelHostName);
}
throw ex;
}
}
else
{
TcpHelper.SendRaw(tunnelHostName, tunnelPort, clientStreamReader.BaseStream);
......@@ -182,7 +182,7 @@ namespace Titanium.Web.Proxy
{
count++;
MemoryStream mw = null;
StreamWriter sw = null;
args = new SessionEventArgs(BUFFER_SIZE);
......@@ -234,7 +234,7 @@ namespace Titanium.Web.Proxy
if ((header[0] == "upgrade") && (header[1] == "websocket"))
{
TcpHelper.SendRaw(httpCmd, tunnelHostName, ref requestLines, args.IsSecure, clientStreamReader.BaseStream);
......@@ -265,7 +265,7 @@ namespace Titanium.Web.Proxy
args.ipAddress = ((IPEndPoint)Client.Client.RemoteEndPoint).Address;
args.IsAlive = args.ProxyRequest.KeepAlive;
BeforeRequest(null, args);
BeforeRequest(null, args);
}
if (args.Cancel)
{
......@@ -286,7 +286,7 @@ namespace Titanium.Web.Proxy
args.ProxyRequest.ConnectionGroupName = connectionGroup;
args.ProxyRequest.AllowWriteStreamBuffering = true;
args.FinishedRequestEvent = new ManualResetEvent(false);
......@@ -632,4 +632,4 @@ namespace Titanium.Web.Proxy
}
}
}
\ No newline at end of file
......@@ -302,9 +302,9 @@ namespace Titanium.Web.Proxy
else
SendChunked(Data, OutStream);
}
}
}
}
\ No newline at end of file
......@@ -74,6 +74,8 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Helpers\Firefox.cs" />
<Compile Include="Helpers\SystemProxy.cs" />
<Compile Include="RequestHandler.cs" />
<Compile Include="ResponseHandler.cs" />
<Compile Include="Helpers\Certificate.cs" />
......@@ -89,8 +91,16 @@
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<None Include="DO_NOT_TRUST_FiddlerRoot.cer">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="makecert.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
......
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ProjectFiles</ProjectView>
</PropertyGroup>
</Project>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment