예제 #1
0
        private void frmSelectSmartcard_Load(object sender, EventArgs e)
        {
            List <string> srv = SmartCards.GetCSPProviders();

            foreach (string s in srv)
            {
                lstSC.Items.Add(s);
            }
            if (lstSC.Items.Count > 0)
            {
                lstSC.SelectedIndex = 0;
            }
        }
예제 #2
0
        static int Main(string[] args)
        {
            if (args.Length < 1)
            {
                Help();
                return(1);
            }

            switch (args[0].ToLower())
            {
            case "-?":
            case "/?":
            case "/h":
            case "-h":
            case "?":
                Help();
                return(1);

            case "listcerts":
            {
                Console.WriteLine("Available certificates:");
                foreach (string s in Certificates.GetCertificates(StoreLocation.CurrentUser))
                {
                    Console.WriteLine("  " + s);
                }
                Console.WriteLine("Available CSPs:");

                foreach (string s in SmartCards.GetCSPProviders())
                {
                    Console.WriteLine("  " + s);
                }
                return(0);
            }

            case "compile":
            {
                if (args.Length < 4)
                {
                    Console.WriteLine("Insufficient argurments.");
                    return(1);
                }
                string     filename = args[1];
                CertMethod certmeth = CertMethod.UNKNOWN;
                switch (args[2].ToLower())
                {
                case "cert":
                    certmeth = CertMethod.CERT;
                    break;

                case "csp":
                    certmeth = CertMethod.CSP;
                    break;
                }
                if (certmeth == CertMethod.UNKNOWN)
                {
                    Console.WriteLine("Unknown certificate method.");
                    return(1);
                }
                string certname = args[3];

                PKGCompilerArgs pkgcompiler = new PKGCompilerArgs();
                pkgcompiler.UseExtSign   = certmeth == CertMethod.CSP ? true : false;
                pkgcompiler.SignCert     = certname;
                pkgcompiler.SignExtCert  = certname;
                pkgcompiler.SignLocation = StoreLocation.CurrentUser;
                pkgcompiler.PIN          = null;

                string          ErrorText;
                PackageCompiler PackageCompiler = new PackageCompiler();
                PackageCompiler.OnStatusUpdate += PackageCompiler_OnStatusUpdate;
                bool res = PackageCompiler.CompilePackage(filename, pkgcompiler, out ErrorText);
                if (res == false)
                {
                    Console.WriteLine("\n" + ErrorText + "\n\nFAILED!\n");
                    return(5);
                }
                Console.WriteLine("Success");
                return(0);
            }

            default:
            {
                Console.WriteLine("Unsupported command");
                break;
            }
            }

            return(1);
        }
예제 #3
0
        private void frmCompilePackage_Load(object sender, EventArgs e)
        {
            lstCert.Items.Clear();
            lstExtSign.Items.Clear();
            string LastCert = "";

            foreach (string s in Certificates.GetCertificates(StoreLocation.CurrentUser))
            {
                if (Settings.Default.LastCertificate == s)
                {
                    LastCert = s;
                }

                lstCert.Items.Add(s);
            }
            if (LastCert != "")
            {
                lstCert.Text = LastCert;
            }

            string LastExtCert = "";

            foreach (string s in SmartCards.GetCSPProviders())
            {
                if (Settings.Default.LastExtCertificate == s)
                {
                    LastExtCert = s;
                }

                lstExtSign.Items.Add(s);
            }
            if (LastExtCert != "")
            {
                lstExtSign.Text = LastExtCert;
            }

            radCertSign.Checked    = true;
            txtOutputFilename.Text = Package.Outputfile;

            lblStatus.Text  = "";
            cmdStop.Enabled = false;

            if (lstCert.Text == "")
            {
                if (lstCert.Items.Count > 0)
                {
                    lstCert.SelectedIndex = 1;
                }
            }

            if (lstExtSign.Text == "")
            {
                if (lstExtSign.Items.Count > 0)
                {
                    lstExtSign.SelectedIndex = 1;
                }
            }

            switch (Settings.Default.LastSelectedCertificateType)
            {
            case "EXT":
                radExtSign.Checked = true;
                break;

            case "INT":
                radCertSign.Checked = true;
                break;
            }
        }