Exemple #1
0
 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());
 }
Exemple #2
0
 private void btnTrust_Click(object sender, EventArgs e)
 {
     if (helper.IsCertTrusted())
     {
         helper.UntrustCertificate();
     }
     else
     {
         helper.TrustCertificate();
     }
     SetTrustedText();
 }