Ejemplo n.º 1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="certificateFolder"></param>
        /// <param name="title"></param>
        /// <param name="systemTitle">If system title is not null this certificate is selected.</param>
        public GXCertificateForm(IGXUpdater updater, string address, string certificateFolder, string title, byte[] systemTitle)
        {
            InitializeComponent();
            _updater = updater;
            _address = address;
            string st = null;

            if (systemTitle != null && systemTitle.Length == 8)
            {
                st = GXAsn1Converter.SystemTitleToSubject(systemTitle);
            }

            Certificates      = new GXx509CertificateCollection();
            CertificateFolder = certificateFolder;
            Title             = title;
            foreach (string p in Directory.GetFiles(CertificateFolder))
            {
                string ext = Path.GetExtension(p);
                if (string.Compare(ext, ".pem", true) == 0 || string.Compare(ext, ".cer", true) == 0)
                {
                    try
                    {
                        GXx509Certificate cert = GXx509Certificate.Load(p);
                        AddCertificate(cert, p, st);
                    }
                    catch (Exception ex)
                    {
                        ListViewItem li = new ListViewItem(new string[] { ex.Message, "", "", "", "", Path.GetFileNameWithoutExtension(p) });
                        li.Tag       = p;
                        li.BackColor = Color.Red;
                        CertificatesList.Items.Add(li);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public GXDeviceCipheringSettings(string address, string title, string keysPath, string certificatesPath)
 {
     InitializeComponent();
     _address          = address;
     _title            = title;
     _keysPath         = keysPath;
     _certificatesPath = certificatesPath;
     _privateKeys      = new GXPkcs8Collection();
     _certifications   = new GXx509CertificateCollection();
     _privateKeys.Import(keysPath);
     _certifications.Import(certificatesPath);
     SigningCb.Items.AddRange(new object[] { Signing.None, Signing.OnePassDiffieHellman, Signing.StaticUnifiedModel, Signing.GeneralSigning });
     SecuritySuiteCb.Items.AddRange(new object[] { SecuritySuite.Suite0, SecuritySuite.Suite1, SecuritySuite.Suite2 });
     SecurityCB.Items.AddRange(new object[] { Security.None, Security.Authentication,
                                              Security.Encryption, Security.AuthenticationEncryption });
     SecurityCB.SelectedIndex      = 0;
     SecuritySuiteCb.SelectedIndex = 0;
     ShowKeys();
     _checkSystemTitle = true;
     updateUI          = true;
 }