static void Main(string[] args) { if (args != null && args.Length > 0) { AttachConsole(ATTACH_PARENT_PROCESS); CertTrustHelper helper = new CertTrustHelper(); if (args[0].ToLower() == "trust") { string error = helper.TrustCertificate(); if (error != null) { Console.Error.WriteLine(error); } else { Console.Write(helper.IsCertTrusted() ? "trusted" : "untrusted"); } } else if (args[0].ToLower() == "untrust") { string error = helper.UntrustCertificate(); if (error != null) { Console.Error.WriteLine(error); } else { Console.Write(helper.IsCertTrusted() ? "trusted" : "untrusted"); } } else if (args[0].ToLower() == "istrusted") { string error = helper.Load(); if (error != null) { Console.Error.WriteLine(error); } else { Console.Write(helper.IsCertTrusted() ? "trusted" : "untrusted"); } } else { FileInfo fiExe = new FileInfo(Application.ExecutablePath); Console.WriteLine("Usage: " + fiExe.Name + " [trust|untrust|istrusted]"); Console.WriteLine("\t\ttrust - The embedded certificate will be trusted"); Console.WriteLine("\t\tuntrust - The embedded certificate will be untrusted"); Console.WriteLine("\t\tistrusted - application will write \"trusted\" or \"untrusted\" to stdout"); } return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); }
private void MainForm_Load(object sender, EventArgs e) { string error = helper.Load(); if (error != null) { lblCertName.Text = error; } else { lblCertName.Text = helper.certName; btnTrust.Enabled = true; SetTrustedText(); } }