Commit 194a5f6f authored by ilushka85's avatar ilushka85

Support for external error logging func - only implemented in cert area

parent 935ca66f
...@@ -195,7 +195,7 @@ namespace Titanium.Web.Proxy.Network ...@@ -195,7 +195,7 @@ namespace Titanium.Web.Proxy.Network
private X509Certificate2 InternalCreateCert(string sSubjectCN, bool isRoot, bool switchToMTAIfNeeded,X509Certificate2 signingCert=null) private X509Certificate2 InternalCreateCert(string sSubjectCN, bool isRoot, bool switchToMTAIfNeeded,X509Certificate2 signingCert=null)
{ {
X509Certificate2 rCert = null; X509Certificate2 rCert=null;
if (switchToMTAIfNeeded && Thread.CurrentThread.GetApartmentState() != ApartmentState.MTA) if (switchToMTAIfNeeded && Thread.CurrentThread.GetApartmentState() != ApartmentState.MTA)
{ {
ManualResetEvent manualResetEvent = new ManualResetEvent(false); ManualResetEvent manualResetEvent = new ManualResetEvent(false);
...@@ -229,7 +229,7 @@ namespace Titanium.Web.Proxy.Network ...@@ -229,7 +229,7 @@ namespace Titanium.Web.Proxy.Network
} }
catch (Exception e) catch (Exception e)
{ {
return null; throw e;
} }
return rCert; return rCert;
} }
......
...@@ -55,22 +55,28 @@ namespace Titanium.Web.Proxy.Network ...@@ -55,22 +55,28 @@ namespace Titanium.Web.Proxy.Network
return true; return true;
} }
} }
catch catch(Exception e)
{ {
ProxyServer.ExceptionFunc(e);
} }
} }
rootCertificate = CreateCertificate(RootCertificateName, true); try
{
rootCertificate = CreateCertificate(RootCertificateName, true);
}
catch(Exception e)
{
ProxyServer.ExceptionFunc(e);
}
if (rootCertificate != null) if (rootCertificate != null)
{ {
try try
{ {
File.WriteAllBytes("rootCert.pfx", rootCertificate.Export(X509ContentType.Pkcs12)); File.WriteAllBytes("rootCert.pfx", rootCertificate.Export(X509ContentType.Pkcs12));
} }
catch catch(Exception e)
{ {
ProxyServer.ExceptionFunc(e);
} }
} }
return rootCertificate != null; return rootCertificate != null;
...@@ -102,7 +108,14 @@ namespace Titanium.Web.Proxy.Network ...@@ -102,7 +108,14 @@ namespace Titanium.Web.Proxy.Network
{ {
if (certificateCache.ContainsKey(certificateName) == false) if (certificateCache.ContainsKey(certificateName) == false)
{ {
certificate = certEngine.CreateCert(certificateName, isRootCertificate, rootCertificate); try
{
certificate = certEngine.CreateCert(certificateName, isRootCertificate, rootCertificate);
}
catch(Exception e)
{
ProxyServer.ExceptionFunc(e);
}
if (certificate != null && !certificateCache.ContainsKey(certificateName)) if (certificate != null && !certificateCache.ContainsKey(certificateName))
{ {
certificateCache.Add(certificateName, new CachedCertificate() { Certificate = certificate }); certificateCache.Add(certificateName, new CachedCertificate() { Certificate = certificate });
......
...@@ -18,6 +18,28 @@ namespace Titanium.Web.Proxy ...@@ -18,6 +18,28 @@ namespace Titanium.Web.Proxy
/// </summary> /// </summary>
public partial class ProxyServer : IDisposable public partial class ProxyServer : IDisposable
{ {
private static Action<Exception> _exceptionFunc=null;
public static Action<Exception> ExceptionFunc
{
get
{
if(_exceptionFunc!=null)
{
return _exceptionFunc;
}
else
{
return (e)=>
{
};
}
}
set
{
_exceptionFunc = value;
}
}
public Func<string, string, Task<bool>> AuthenticateUserFunc public Func<string, string, Task<bool>> AuthenticateUserFunc
{ {
get; get;
......
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