Commit 4e203c3a authored by jmh76's avatar jmh76

Merge remote-tracking branch 'upstream/master'

parents 5cb49c70 352de4a8
...@@ -165,19 +165,19 @@ ...@@ -165,19 +165,19 @@
</h3> </h3>
<span class="small pull-right mobile-hide"> <span class="small pull-right mobile-hide">
<span class="divider">|</span> <span class="divider">|</span>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Exceptions_ProxyConnectException_ConnectEventArgs.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Exceptions.ProxyConnectException.ConnectEventArgs%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a> <a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Exceptions_ProxyConnectException_Session.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Exceptions.ProxyConnectException.Session%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span> </span>
<span class="small pull-right mobile-hide"> <span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Exceptions/ProxyConnectException.cs/#L29">View Source</a> <a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Exceptions/ProxyConnectException.cs/#L29">View Source</a>
</span> </span>
<a id="Titanium_Web_Proxy_Exceptions_ProxyConnectException_ConnectEventArgs_" data-uid="Titanium.Web.Proxy.Exceptions.ProxyConnectException.ConnectEventArgs*"></a> <a id="Titanium_Web_Proxy_Exceptions_ProxyConnectException_Session_" data-uid="Titanium.Web.Proxy.Exceptions.ProxyConnectException.Session*"></a>
<h4 id="Titanium_Web_Proxy_Exceptions_ProxyConnectException_ConnectEventArgs" data-uid="Titanium.Web.Proxy.Exceptions.ProxyConnectException.ConnectEventArgs">ConnectEventArgs</h4> <h4 id="Titanium_Web_Proxy_Exceptions_ProxyConnectException_Session" data-uid="Titanium.Web.Proxy.Exceptions.ProxyConnectException.Session">Session</h4>
<div class="markdown level1 summary"><p>Gets session info associated to the exception.</p> <div class="markdown level1 summary"><p>Gets session info associated to the exception.</p>
</div> </div>
<div class="markdown level1 conceptual"></div> <div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5> <h5 class="decalaration">Declaration</h5>
<div class="codewrapper"> <div class="codewrapper">
<pre><code class="lang-csharp hljs">public TunnelConnectSessionEventArgs ConnectEventArgs { get; }</code></pre> <pre><code class="lang-csharp hljs">public SessionEventArgsBase Session { get; }</code></pre>
</div> </div>
<h5 class="propertyValue">Property Value</h5> <h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-striped table-condensed"> <table class="table table-bordered table-striped table-condensed">
...@@ -189,12 +189,12 @@ ...@@ -189,12 +189,12 @@
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td><a class="xref" href="Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs.html">TunnelConnectSessionEventArgs</a></td> <td><a class="xref" href="Titanium.Web.Proxy.EventArguments.SessionEventArgsBase.html">SessionEventArgsBase</a></td>
<td></td> <td></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<h5 id="Titanium_Web_Proxy_Exceptions_ProxyConnectException_ConnectEventArgs_remarks">Remarks</h5> <h5 id="Titanium_Web_Proxy_Exceptions_ProxyConnectException_Session_remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This object properties should not be edited.</p> <div class="markdown level1 remarks"><p>This object properties should not be edited.</p>
</div> </div>
<h3 id="implements">Implements</h3> <h3 id="implements">Implements</h3>
......
...@@ -165,19 +165,19 @@ ...@@ -165,19 +165,19 @@
</h3> </h3>
<span class="small pull-right mobile-hide"> <span class="small pull-right mobile-hide">
<span class="divider">|</span> <span class="divider">|</span>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Exceptions_ProxyHttpException_SessionEventArgs.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Exceptions.ProxyHttpException.SessionEventArgs%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a> <a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Exceptions_ProxyHttpException_Session.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Exceptions.ProxyHttpException.Session%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span> </span>
<span class="small pull-right mobile-hide"> <span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Exceptions/ProxyHttpException.cs/#L29">View Source</a> <a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Exceptions/ProxyHttpException.cs/#L29">View Source</a>
</span> </span>
<a id="Titanium_Web_Proxy_Exceptions_ProxyHttpException_SessionEventArgs_" data-uid="Titanium.Web.Proxy.Exceptions.ProxyHttpException.SessionEventArgs*"></a> <a id="Titanium_Web_Proxy_Exceptions_ProxyHttpException_Session_" data-uid="Titanium.Web.Proxy.Exceptions.ProxyHttpException.Session*"></a>
<h4 id="Titanium_Web_Proxy_Exceptions_ProxyHttpException_SessionEventArgs" data-uid="Titanium.Web.Proxy.Exceptions.ProxyHttpException.SessionEventArgs">SessionEventArgs</h4> <h4 id="Titanium_Web_Proxy_Exceptions_ProxyHttpException_Session" data-uid="Titanium.Web.Proxy.Exceptions.ProxyHttpException.Session">Session</h4>
<div class="markdown level1 summary"><p>Gets session info associated to the exception.</p> <div class="markdown level1 summary"><p>Gets session info associated to the exception.</p>
</div> </div>
<div class="markdown level1 conceptual"></div> <div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5> <h5 class="decalaration">Declaration</h5>
<div class="codewrapper"> <div class="codewrapper">
<pre><code class="lang-csharp hljs">public SessionEventArgs SessionEventArgs { get; }</code></pre> <pre><code class="lang-csharp hljs">public SessionEventArgs Session { get; }</code></pre>
</div> </div>
<h5 class="propertyValue">Property Value</h5> <h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-striped table-condensed"> <table class="table table-bordered table-striped table-condensed">
...@@ -194,7 +194,7 @@ ...@@ -194,7 +194,7 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<h5 id="Titanium_Web_Proxy_Exceptions_ProxyHttpException_SessionEventArgs_remarks">Remarks</h5> <h5 id="Titanium_Web_Proxy_Exceptions_ProxyHttpException_Session_remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This object properties should not be edited.</p> <div class="markdown level1 remarks"><p>This object properties should not be edited.</p>
</div> </div>
<h3 id="implements">Implements</h3> <h3 id="implements">Implements</h3>
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
"api/Titanium.Web.Proxy.Exceptions.ProxyConnectException.html": { "api/Titanium.Web.Proxy.Exceptions.ProxyConnectException.html": {
"href": "api/Titanium.Web.Proxy.Exceptions.ProxyConnectException.html", "href": "api/Titanium.Web.Proxy.Exceptions.ProxyConnectException.html",
"title": "Class ProxyConnectException | Titanium Web Proxy", "title": "Class ProxyConnectException | Titanium Web Proxy",
"keywords": "Class ProxyConnectException Proxy Connection exception. Inheritance Object Exception ProxyException ProxyConnectException Implements ISerializable _Exception Inherited Members Exception.GetBaseException() Exception.ToString() Exception.GetObjectData(SerializationInfo, StreamingContext) Exception.GetType() Exception.Message Exception.Data Exception.InnerException Exception.TargetSite Exception.StackTrace Exception.HelpLink Exception.Source Exception.HResult Exception.SerializeObjectState Object.Equals(Object) Object.Equals(Object, Object) Object.ReferenceEquals(Object, Object) Object.GetHashCode() Object.MemberwiseClone() Namespace : Titanium.Web.Proxy.Exceptions Assembly : Titanium.Web.Proxy.dll Syntax public class ProxyConnectException : ProxyException, ISerializable, _Exception Properties | Improve this Doc View Source ConnectEventArgs Gets session info associated to the exception. Declaration public TunnelConnectSessionEventArgs ConnectEventArgs { get; } Property Value Type Description TunnelConnectSessionEventArgs Remarks This object properties should not be edited. Implements System.Runtime.Serialization.ISerializable System.Runtime.InteropServices._Exception" "keywords": "Class ProxyConnectException Proxy Connection exception. Inheritance Object Exception ProxyException ProxyConnectException Implements ISerializable _Exception Inherited Members Exception.GetBaseException() Exception.ToString() Exception.GetObjectData(SerializationInfo, StreamingContext) Exception.GetType() Exception.Message Exception.Data Exception.InnerException Exception.TargetSite Exception.StackTrace Exception.HelpLink Exception.Source Exception.HResult Exception.SerializeObjectState Object.Equals(Object) Object.Equals(Object, Object) Object.ReferenceEquals(Object, Object) Object.GetHashCode() Object.MemberwiseClone() Namespace : Titanium.Web.Proxy.Exceptions Assembly : Titanium.Web.Proxy.dll Syntax public class ProxyConnectException : ProxyException, ISerializable, _Exception Properties | Improve this Doc View Source Session Gets session info associated to the exception. Declaration public SessionEventArgsBase Session { get; } Property Value Type Description SessionEventArgsBase Remarks This object properties should not be edited. Implements System.Runtime.Serialization.ISerializable System.Runtime.InteropServices._Exception"
}, },
"api/Titanium.Web.Proxy.Exceptions.ProxyException.html": { "api/Titanium.Web.Proxy.Exceptions.ProxyException.html": {
"href": "api/Titanium.Web.Proxy.Exceptions.ProxyException.html", "href": "api/Titanium.Web.Proxy.Exceptions.ProxyException.html",
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
"api/Titanium.Web.Proxy.Exceptions.ProxyHttpException.html": { "api/Titanium.Web.Proxy.Exceptions.ProxyHttpException.html": {
"href": "api/Titanium.Web.Proxy.Exceptions.ProxyHttpException.html", "href": "api/Titanium.Web.Proxy.Exceptions.ProxyHttpException.html",
"title": "Class ProxyHttpException | Titanium Web Proxy", "title": "Class ProxyHttpException | Titanium Web Proxy",
"keywords": "Class ProxyHttpException Proxy HTTP exception. Inheritance Object Exception ProxyException ProxyHttpException Implements ISerializable _Exception Inherited Members Exception.GetBaseException() Exception.ToString() Exception.GetObjectData(SerializationInfo, StreamingContext) Exception.GetType() Exception.Message Exception.Data Exception.InnerException Exception.TargetSite Exception.StackTrace Exception.HelpLink Exception.Source Exception.HResult Exception.SerializeObjectState Object.Equals(Object) Object.Equals(Object, Object) Object.ReferenceEquals(Object, Object) Object.GetHashCode() Object.MemberwiseClone() Namespace : Titanium.Web.Proxy.Exceptions Assembly : Titanium.Web.Proxy.dll Syntax public class ProxyHttpException : ProxyException, ISerializable, _Exception Properties | Improve this Doc View Source SessionEventArgs Gets session info associated to the exception. Declaration public SessionEventArgs SessionEventArgs { get; } Property Value Type Description SessionEventArgs Remarks This object properties should not be edited. Implements System.Runtime.Serialization.ISerializable System.Runtime.InteropServices._Exception" "keywords": "Class ProxyHttpException Proxy HTTP exception. Inheritance Object Exception ProxyException ProxyHttpException Implements ISerializable _Exception Inherited Members Exception.GetBaseException() Exception.ToString() Exception.GetObjectData(SerializationInfo, StreamingContext) Exception.GetType() Exception.Message Exception.Data Exception.InnerException Exception.TargetSite Exception.StackTrace Exception.HelpLink Exception.Source Exception.HResult Exception.SerializeObjectState Object.Equals(Object) Object.Equals(Object, Object) Object.ReferenceEquals(Object, Object) Object.GetHashCode() Object.MemberwiseClone() Namespace : Titanium.Web.Proxy.Exceptions Assembly : Titanium.Web.Proxy.dll Syntax public class ProxyHttpException : ProxyException, ISerializable, _Exception Properties | Improve this Doc View Source Session Gets session info associated to the exception. Declaration public SessionEventArgs Session { get; } Property Value Type Description SessionEventArgs Remarks This object properties should not be edited. Implements System.Runtime.Serialization.ISerializable System.Runtime.InteropServices._Exception"
}, },
"api/Titanium.Web.Proxy.Exceptions.ServerConnectionException.html": { "api/Titanium.Web.Proxy.Exceptions.ServerConnectionException.html": {
"href": "api/Titanium.Web.Proxy.Exceptions.ServerConnectionException.html", "href": "api/Titanium.Web.Proxy.Exceptions.ServerConnectionException.html",
......
...@@ -797,19 +797,19 @@ references: ...@@ -797,19 +797,19 @@ references:
commentId: T:Titanium.Web.Proxy.Exceptions.ProxyConnectException commentId: T:Titanium.Web.Proxy.Exceptions.ProxyConnectException
fullName: Titanium.Web.Proxy.Exceptions.ProxyConnectException fullName: Titanium.Web.Proxy.Exceptions.ProxyConnectException
nameWithType: ProxyConnectException nameWithType: ProxyConnectException
- uid: Titanium.Web.Proxy.Exceptions.ProxyConnectException.ConnectEventArgs - uid: Titanium.Web.Proxy.Exceptions.ProxyConnectException.Session
name: ConnectEventArgs name: Session
href: api/Titanium.Web.Proxy.Exceptions.ProxyConnectException.html#Titanium_Web_Proxy_Exceptions_ProxyConnectException_ConnectEventArgs href: api/Titanium.Web.Proxy.Exceptions.ProxyConnectException.html#Titanium_Web_Proxy_Exceptions_ProxyConnectException_Session
commentId: P:Titanium.Web.Proxy.Exceptions.ProxyConnectException.ConnectEventArgs commentId: P:Titanium.Web.Proxy.Exceptions.ProxyConnectException.Session
fullName: Titanium.Web.Proxy.Exceptions.ProxyConnectException.ConnectEventArgs fullName: Titanium.Web.Proxy.Exceptions.ProxyConnectException.Session
nameWithType: ProxyConnectException.ConnectEventArgs nameWithType: ProxyConnectException.Session
- uid: Titanium.Web.Proxy.Exceptions.ProxyConnectException.ConnectEventArgs* - uid: Titanium.Web.Proxy.Exceptions.ProxyConnectException.Session*
name: ConnectEventArgs name: Session
href: api/Titanium.Web.Proxy.Exceptions.ProxyConnectException.html#Titanium_Web_Proxy_Exceptions_ProxyConnectException_ConnectEventArgs_ href: api/Titanium.Web.Proxy.Exceptions.ProxyConnectException.html#Titanium_Web_Proxy_Exceptions_ProxyConnectException_Session_
commentId: Overload:Titanium.Web.Proxy.Exceptions.ProxyConnectException.ConnectEventArgs commentId: Overload:Titanium.Web.Proxy.Exceptions.ProxyConnectException.Session
isSpec: "True" isSpec: "True"
fullName: Titanium.Web.Proxy.Exceptions.ProxyConnectException.ConnectEventArgs fullName: Titanium.Web.Proxy.Exceptions.ProxyConnectException.Session
nameWithType: ProxyConnectException.ConnectEventArgs nameWithType: ProxyConnectException.Session
- uid: Titanium.Web.Proxy.Exceptions.ProxyException - uid: Titanium.Web.Proxy.Exceptions.ProxyException
name: ProxyException name: ProxyException
href: api/Titanium.Web.Proxy.Exceptions.ProxyException.html href: api/Titanium.Web.Proxy.Exceptions.ProxyException.html
...@@ -841,19 +841,19 @@ references: ...@@ -841,19 +841,19 @@ references:
commentId: T:Titanium.Web.Proxy.Exceptions.ProxyHttpException commentId: T:Titanium.Web.Proxy.Exceptions.ProxyHttpException
fullName: Titanium.Web.Proxy.Exceptions.ProxyHttpException fullName: Titanium.Web.Proxy.Exceptions.ProxyHttpException
nameWithType: ProxyHttpException nameWithType: ProxyHttpException
- uid: Titanium.Web.Proxy.Exceptions.ProxyHttpException.SessionEventArgs - uid: Titanium.Web.Proxy.Exceptions.ProxyHttpException.Session
name: SessionEventArgs name: Session
href: api/Titanium.Web.Proxy.Exceptions.ProxyHttpException.html#Titanium_Web_Proxy_Exceptions_ProxyHttpException_SessionEventArgs href: api/Titanium.Web.Proxy.Exceptions.ProxyHttpException.html#Titanium_Web_Proxy_Exceptions_ProxyHttpException_Session
commentId: P:Titanium.Web.Proxy.Exceptions.ProxyHttpException.SessionEventArgs commentId: P:Titanium.Web.Proxy.Exceptions.ProxyHttpException.Session
fullName: Titanium.Web.Proxy.Exceptions.ProxyHttpException.SessionEventArgs fullName: Titanium.Web.Proxy.Exceptions.ProxyHttpException.Session
nameWithType: ProxyHttpException.SessionEventArgs nameWithType: ProxyHttpException.Session
- uid: Titanium.Web.Proxy.Exceptions.ProxyHttpException.SessionEventArgs* - uid: Titanium.Web.Proxy.Exceptions.ProxyHttpException.Session*
name: SessionEventArgs name: Session
href: api/Titanium.Web.Proxy.Exceptions.ProxyHttpException.html#Titanium_Web_Proxy_Exceptions_ProxyHttpException_SessionEventArgs_ href: api/Titanium.Web.Proxy.Exceptions.ProxyHttpException.html#Titanium_Web_Proxy_Exceptions_ProxyHttpException_Session_
commentId: Overload:Titanium.Web.Proxy.Exceptions.ProxyHttpException.SessionEventArgs commentId: Overload:Titanium.Web.Proxy.Exceptions.ProxyHttpException.Session
isSpec: "True" isSpec: "True"
fullName: Titanium.Web.Proxy.Exceptions.ProxyHttpException.SessionEventArgs fullName: Titanium.Web.Proxy.Exceptions.ProxyHttpException.Session
nameWithType: ProxyHttpException.SessionEventArgs nameWithType: ProxyHttpException.Session
- uid: Titanium.Web.Proxy.Exceptions.ServerConnectionException - uid: Titanium.Web.Proxy.Exceptions.ServerConnectionException
name: ServerConnectionException name: ServerConnectionException
href: api/Titanium.Web.Proxy.Exceptions.ServerConnectionException.html href: api/Titanium.Web.Proxy.Exceptions.ServerConnectionException.html
......
...@@ -13,11 +13,11 @@ namespace Titanium.Web.Proxy.Exceptions ...@@ -13,11 +13,11 @@ namespace Titanium.Web.Proxy.Exceptions
/// </summary> /// </summary>
/// <param name="message">Message for this exception</param> /// <param name="message">Message for this exception</param>
/// <param name="innerException">Associated inner exception</param> /// <param name="innerException">Associated inner exception</param>
/// <param name="connectEventArgs">Instance of <see cref="EventArguments.TunnelConnectSessionEventArgs" /> associated to the exception</param> /// <param name="session">Instance of <see cref="EventArguments.TunnelConnectSessionEventArgs" /> associated to the exception</param>
internal ProxyConnectException(string message, Exception innerException, TunnelConnectSessionEventArgs connectEventArgs) : base( internal ProxyConnectException(string message, Exception innerException, SessionEventArgsBase session) : base(
message, innerException) message, innerException)
{ {
ConnectEventArgs = connectEventArgs; Session = session;
} }
/// <summary> /// <summary>
...@@ -26,6 +26,6 @@ namespace Titanium.Web.Proxy.Exceptions ...@@ -26,6 +26,6 @@ namespace Titanium.Web.Proxy.Exceptions
/// <remarks> /// <remarks>
/// This object properties should not be edited. /// This object properties should not be edited.
/// </remarks> /// </remarks>
public TunnelConnectSessionEventArgs ConnectEventArgs { get; } public SessionEventArgsBase Session { get; }
} }
} }
...@@ -13,11 +13,11 @@ namespace Titanium.Web.Proxy.Exceptions ...@@ -13,11 +13,11 @@ namespace Titanium.Web.Proxy.Exceptions
/// </summary> /// </summary>
/// <param name="message">Message for this exception</param> /// <param name="message">Message for this exception</param>
/// <param name="innerException">Associated inner exception</param> /// <param name="innerException">Associated inner exception</param>
/// <param name="sessionEventArgs">Instance of <see cref="EventArguments.SessionEventArgs" /> associated to the exception</param> /// <param name="session">Instance of <see cref="EventArguments.SessionEventArgs" /> associated to the exception</param>
internal ProxyHttpException(string message, Exception innerException, SessionEventArgs sessionEventArgs) : base( internal ProxyHttpException(string message, Exception innerException, SessionEventArgs session) : base(
message, innerException) message, innerException)
{ {
SessionEventArgs = sessionEventArgs; Session = session;
} }
/// <summary> /// <summary>
...@@ -26,6 +26,6 @@ namespace Titanium.Web.Proxy.Exceptions ...@@ -26,6 +26,6 @@ namespace Titanium.Web.Proxy.Exceptions
/// <remarks> /// <remarks>
/// This object properties should not be edited. /// This object properties should not be edited.
/// </remarks> /// </remarks>
public SessionEventArgs SessionEventArgs { get; } public SessionEventArgs Session { get; }
} }
} }
...@@ -41,11 +41,13 @@ namespace Titanium.Web.Proxy ...@@ -41,11 +41,13 @@ namespace Titanium.Web.Proxy
bool closeServerConnection = false; bool closeServerConnection = false;
bool calledRequestHandler = false; bool calledRequestHandler = false;
SslStream sslStream = null;
try try
{ {
string connectHostname = null; string connectHostname = null;
TunnelConnectSessionEventArgs connectArgs = null; TunnelConnectSessionEventArgs connectArgs = null;
// Client wants to create a secure tcp tunnel (probably its a HTTPS or Websocket request) // Client wants to create a secure tcp tunnel (probably its a HTTPS or Websocket request)
if (await HttpHelper.IsConnectMethod(clientStream) == 1) if (await HttpHelper.IsConnectMethod(clientStream) == 1)
...@@ -150,8 +152,6 @@ namespace Titanium.Web.Proxy ...@@ -150,8 +152,6 @@ namespace Titanium.Web.Proxy
await tcpConnectionFactory.Release(connection, true); await tcpConnectionFactory.Release(connection, true);
} }
SslStream sslStream = null;
if (EnableTcpServerConnectionPrefetch) if (EnableTcpServerConnectionPrefetch)
{ {
//don't pass cancellation token here //don't pass cancellation token here
...@@ -161,13 +161,13 @@ namespace Titanium.Web.Proxy ...@@ -161,13 +161,13 @@ namespace Titanium.Web.Proxy
cancellationToken: CancellationToken.None); cancellationToken: CancellationToken.None);
} }
X509Certificate2 certificate = null;
try try
{ {
sslStream = new SslStream(clientStream); sslStream = new SslStream(clientStream, true);
string certName = HttpHelper.GetWildCardDomainName(connectHostname); string certName = HttpHelper.GetWildCardDomainName(connectHostname);
certificate = endPoint.GenericCertificate ??
var certificate = endPoint.GenericCertificate ??
await CertificateManager.CreateServerCertificate(certName); await CertificateManager.CreateServerCertificate(certName);
// Successfully managed to authenticate the client using the fake certificate // Successfully managed to authenticate the client using the fake certificate
...@@ -197,9 +197,9 @@ namespace Titanium.Web.Proxy ...@@ -197,9 +197,9 @@ namespace Titanium.Web.Proxy
} }
catch (Exception e) catch (Exception e)
{ {
sslStream?.Dispose(); var certname = certificate?.GetNameInfo(X509NameType.SimpleName, false);
throw new ProxyConnectException( throw new ProxyConnectException(
$"Could'nt authenticate client '{connectHostname}' with fake certificate.", e, connectArgs); $"Couldn't authenticate host '{connectHostname}' with certificate '{certname}'.", e, connectArgs);
} }
if (await HttpHelper.IsConnectMethod(clientStream) == -1) if (await HttpHelper.IsConnectMethod(clientStream) == -1)
...@@ -350,6 +350,7 @@ namespace Titanium.Web.Proxy ...@@ -350,6 +350,7 @@ namespace Titanium.Web.Proxy
await tcpConnectionFactory.Release(prefetchConnectionTask, closeServerConnection); await tcpConnectionFactory.Release(prefetchConnectionTask, closeServerConnection);
} }
sslStream?.Dispose();
clientStream.Dispose(); clientStream.Dispose();
if (!cancellationTokenSource.IsCancellationRequested) if (!cancellationTokenSource.IsCancellationRequested)
......
...@@ -4,6 +4,7 @@ using System.IO; ...@@ -4,6 +4,7 @@ using System.IO;
using System.Net.Security; using System.Net.Security;
using System.Net.Sockets; using System.Net.Sockets;
using System.Security.Authentication; using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using StreamExtended; using StreamExtended;
...@@ -34,6 +35,8 @@ namespace Titanium.Web.Proxy ...@@ -34,6 +35,8 @@ namespace Titanium.Web.Proxy
var clientStream = new CustomBufferedStream(clientConnection.GetStream(), BufferPool, BufferSize); var clientStream = new CustomBufferedStream(clientConnection.GetStream(), BufferPool, BufferSize);
var clientStreamWriter = new HttpResponseWriter(clientStream, BufferPool, BufferSize); var clientStreamWriter = new HttpResponseWriter(clientStream, BufferPool, BufferSize);
SslStream sslStream = null;
try try
{ {
var clientHelloInfo = await SslTools.PeekClientHello(clientStream, BufferPool, cancellationToken); var clientHelloInfo = await SslTools.PeekClientHello(clientStream, BufferPool, cancellationToken);
...@@ -60,18 +63,17 @@ namespace Titanium.Web.Proxy ...@@ -60,18 +63,17 @@ namespace Titanium.Web.Proxy
if (endPoint.DecryptSsl && args.DecryptSsl) if (endPoint.DecryptSsl && args.DecryptSsl)
{ {
SslStream sslStream = null; //do client authentication using certificate
X509Certificate2 certificate = null;
//do client authentication using fake certificate
try try
{ {
sslStream = new SslStream(clientStream); sslStream = new SslStream(clientStream, true);
string certName = HttpHelper.GetWildCardDomainName(httpsHostName); string certName = HttpHelper.GetWildCardDomainName(httpsHostName);
var certificate = endPoint.GenericCertificate ?? certificate = endPoint.GenericCertificate ??
await CertificateManager.CreateServerCertificate(certName); await CertificateManager.CreateServerCertificate(certName);
// Successfully managed to authenticate the client using the fake certificate // Successfully managed to authenticate the client using the certificate
await sslStream.AuthenticateAsServerAsync(certificate, false, SslProtocols.Tls, false); await sslStream.AuthenticateAsServerAsync(certificate, false, SslProtocols.Tls, false);
// HTTPS server created - we can now decrypt the client's traffic // HTTPS server created - we can now decrypt the client's traffic
...@@ -81,10 +83,16 @@ namespace Titanium.Web.Proxy ...@@ -81,10 +83,16 @@ namespace Titanium.Web.Proxy
} }
catch (Exception e) catch (Exception e)
{ {
sslStream?.Dispose(); var certname = certificate?.GetNameInfo(X509NameType.SimpleName, false);
var session = new SessionEventArgs(this, endPoint, cancellationTokenSource)
{
ProxyClient = { Connection = clientConnection },
HttpClient = { ConnectRequest = null }
};
throw new ProxyConnectException( throw new ProxyConnectException(
$"Could'nt authenticate client '{httpsHostName}' with fake certificate.", e, null); $"Couldn't authenticate host '{httpsHostName}' with certificate '{certname}'.", e, session);
} }
} }
else else
{ {
...@@ -150,8 +158,9 @@ namespace Titanium.Web.Proxy ...@@ -150,8 +158,9 @@ namespace Titanium.Web.Proxy
} }
finally finally
{ {
sslStream?.Dispose();
clientStream.Dispose(); clientStream.Dispose();
if (!cancellationTokenSource.IsCancellationRequested) if (!cancellationTokenSource.IsCancellationRequested)
{ {
cancellationTokenSource.Cancel(); cancellationTokenSource.Cancel();
......
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