diff --git a/TGCommandLine/Program.cs b/TGCommandLine/Program.cs index 494cbd8bd6..0d45e1573a 100644 --- a/TGCommandLine/Program.cs +++ b/TGCommandLine/Program.cs @@ -97,17 +97,6 @@ namespace TGCommandLine static void ReplaceInterface(Interface I) { - - if (!interactive) - I.SetBadCertificateHandler((message) => - { - foreach (var J in Environment.GetCommandLineArgs()) - if (J.ToLower() == "--disable-ssl-verification") //im just not even going to document this because i hate it so much - return true; - return false; - }); - else - I.SetBadCertificateHandler(BadCertificateInteractive); currentInterface = I; ConsoleCommand.Interface = I; } @@ -161,10 +150,20 @@ namespace TGCommandLine ReplaceInterface(new Interface()); Command.OutputProcVar.Value = Console.WriteLine; if (args.Length != 0) + { + Interface.SetBadCertificateHandler((message) => + { + foreach (var J in args) + if (J.ToLower() == "--disable-ssl-verification") //im just not even going to document this because i hate it so much + return true; + return false; + }); return (int)RunCommandLine(new List(args)); + } - Console.WriteLine("Type 'remote' to connect to a remote service"); //interactive mode + Interface.SetBadCertificateHandler(BadCertificateInteractive); + Console.WriteLine("Type 'remote' to connect to a remote service"); while (true) { Console.Write("Enter command: "); diff --git a/TGControlPanel/Program.cs b/TGControlPanel/Program.cs index 0c012c7123..1121948ccb 100644 --- a/TGControlPanel/Program.cs +++ b/TGControlPanel/Program.cs @@ -19,6 +19,7 @@ namespace TGControlPanel } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); + Interface.SetBadCertificateHandler(BadCertificateHandler); using(var L = new Login()) Application.Run(L); } diff --git a/TGServiceInterface/Interface.cs b/TGServiceInterface/Interface.cs index 954b4cc064..8c5533d72d 100644 --- a/TGServiceInterface/Interface.cs +++ b/TGServiceInterface/Interface.cs @@ -101,7 +101,7 @@ namespace TGServiceInterface /// Sets the function called when a remote login fails due to the server having an invalid SSL cert /// /// The to be called when a remote login is attempted while the server posesses a bad certificate. Passed a of error information about the and should return if it the connection should be made anyway - public void SetBadCertificateHandler(Func handler) + public static void SetBadCertificateHandler(Func handler) { ServicePointManager.ServerCertificateValidationCallback = (sender, cert, chain, error) => { @@ -123,7 +123,7 @@ namespace TGServiceInterface ErrorMessage = "An unknown error occurred."; break; } - ErrorMessage = String.Format("The certificate failed to verify for {0}:{1}. {2} {3}", HTTPSURL, HTTPSPort, ErrorMessage, cert.ToString()); + ErrorMessage = String.Format("The certificate failed to verify! Error: {2} Cert: {3}", ErrorMessage, cert.ToString()); return handler(ErrorMessage); }; }