Commit 77f0fdde authored by mohammadlachgar's avatar mohammadlachgar Committed by GitHub

change ProxyEndPoints.Any to ProxyEndPoints.OfType

change 
if (ProxyEndPoints.Any(x => (x as ExplicitProxyEndPoint).GenericCertificate == null))
to
if (ProxyEndPoints.OfType<ExplicitProxyEndPoint>().Any(x => x.GenericCertificate == null))
and add 
 throw new Exception(ex.Message);
parent 8fb9e60f
using StreamExtended.Network; using StreamExtended.Network;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
...@@ -42,15 +42,15 @@ namespace Titanium.Web.Proxy ...@@ -42,15 +42,15 @@ namespace Titanium.Web.Proxy
/// </summary> /// </summary>
private bool trustRootCertificate; private bool trustRootCertificate;
private bool saveCertificate = false; private bool saveCertificate=false;
/// <summary> /// <summary>
/// Password for export and load rootCert.pfx /// Password for export and load rootCert.pfx
/// </summary> /// </summary>
private string password_rootCert = string.Empty; private string password_rootCert = string.Empty;
/// <summary> /// <summary>
/// Backing field for corresponding public property /// Backing field for corresponding public property
...@@ -152,7 +152,7 @@ namespace Titanium.Web.Proxy ...@@ -152,7 +152,7 @@ namespace Titanium.Web.Proxy
set set
{ {
saveCertificate = value; saveCertificate = value;
CertificateManager.SaveCertificate = saveCertificate; CertificateManager.SaveCertificate = saveCertificate;
} }
} }
...@@ -170,7 +170,7 @@ namespace Titanium.Web.Proxy ...@@ -170,7 +170,7 @@ namespace Titanium.Web.Proxy
} }
} }
/// <summary> /// <summary>
/// Select Certificate Engine /// Select Certificate Engine
...@@ -374,12 +374,12 @@ namespace Titanium.Web.Proxy ...@@ -374,12 +374,12 @@ namespace Titanium.Web.Proxy
/// <param name="endPoint"></param> /// <param name="endPoint"></param>
public void AddEndPoint(ProxyEndPoint endPoint) public void AddEndPoint(ProxyEndPoint endPoint)
{ {
if (ProxyEndPoints.Any(x => x.IpAddress.Equals(endPoint.IpAddress) && endPoint.Port != 0 && x.Port == endPoint.Port)) if (ProxyEndPoints.Any(x => x.IpAddress.Equals(endPoint.IpAddress) && endPoint.Port != 0 && x.Port == endPoint.Port))
{ {
throw new Exception("Cannot add another endpoint to same port & ip address"); throw new Exception("Cannot add another endpoint to same port & ip address");
} }
ProxyEndPoints.Add(endPoint); ProxyEndPoints.Add(endPoint);
if (ProxyRunning) if (ProxyRunning)
...@@ -449,7 +449,7 @@ namespace Titanium.Web.Proxy ...@@ -449,7 +449,7 @@ namespace Titanium.Web.Proxy
if (!endPoint.EnableSsl) if (!endPoint.EnableSsl)
{ {
throw new Exception("Endpoint do not support Https connections"); throw new Exception("Endpoint do not support Https connections");
} }
EnsureRootCertificate(); EnsureRootCertificate();
//If certificate was trusted by the machine //If certificate was trusted by the machine
...@@ -564,15 +564,15 @@ namespace Titanium.Web.Proxy ...@@ -564,15 +564,15 @@ namespace Titanium.Web.Proxy
} }
try try {
{ if (ProxyEndPoints.OfType<ExplicitProxyEndPoint>().Any(x => x.GenericCertificate == null))
if (ProxyEndPoints.Any(x => (x as ExplicitProxyEndPoint).GenericCertificate == null)) {
{
EnsureRootCertificate(); EnsureRootCertificate();
} }
} }
catch 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)
...@@ -747,9 +747,9 @@ namespace Titanium.Web.Proxy ...@@ -747,9 +747,9 @@ namespace Titanium.Web.Proxy
return Task.FromResult(proxy); return Task.FromResult(proxy);
} }
/// <summary> /// <summary>
/// Load or Create Certificate : after "Test Is the root certificate used by this proxy is valid?" /// Load or Create Certificate : after "Test Is the root certificate used by this proxy is valid?"
/// <param name="TrustRootCertificate">"Make current machine trust the Root Certificate used by this proxy" ==> True or False</param> /// <param name="TrustRootCertificate">"Make current machine trust the Root Certificate used by this proxy" ==> True or False</param>
/// </summary> /// </summary>
public void EnsureRootCertificate(bool TrustRootCertificate) public void EnsureRootCertificate(bool TrustRootCertificate)
{ {
...@@ -761,7 +761,7 @@ namespace Titanium.Web.Proxy ...@@ -761,7 +761,7 @@ namespace Titanium.Web.Proxy
{ {
if (!CertificateManager.CertValidated) if (!CertificateManager.CertValidated)
{ {
CertificateManager.CreateTrustedRootCertificate(); CertificateManager.CreateTrustedRootCertificate();
if (TrustRootCertificate) if (TrustRootCertificate)
...@@ -771,7 +771,7 @@ namespace Titanium.Web.Proxy ...@@ -771,7 +771,7 @@ namespace Titanium.Web.Proxy
} }
} }
/// <summary> /// <summary>
/// When a connection is received from client act /// When a connection is received from client act
......
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