public CertificateHelper()
 {
     foreach (string s in Settings.Default.Clients)
     {
         string[] spl = s.Split(',');
         if (spl.Length != 2)
         {
             throw new ConfigurationException(("en", "Invalid Client line in configuration"), ("es", "La Linea del cliente en la configuracion es invalida"));
         }
         X509Certificate2 priv = SearchCertificate(spl[1].Trim());
         if (priv == null)
         {
             throw new CertificateException(("en", $"Unable to find Certificate '{spl[1].Trim()}' in the X509 Store, please make sure that the user using this context has security access to the certificate"), ("en", $"No puedo encontar el certificado '{spl[1].Trim()}' el el Store de Certficado, asegurese que el certificado este instalado, y que el usuario que corrar el contexto de la aplicacion tenga permisos para acceder a este"));
         }
         ClientSignKeys.Add(spl[0].Trim(), new SignatureHelper(priv, true));
     }
     foreach (string s in Settings.Default.Issuers)
     {
         string[] spl = s.Split(',');
         if (spl.Length != 2)
         {
             throw new ConfigurationException(("en", "Invalid Isser line in configuration"), ("es", "La Linea del sello en la configuracion es invalida"));
         }
         X509Certificate2 priv = SearchCertificate(spl[1].Trim());
         if (priv == null)
         {
             throw new CertificateException(("en", $"Unable to find Certificate '{spl[1].Trim()}' in the X509 Store, please make sure that the user using this context has security access to the certificate"), ("en", $"No puedo encontar el certificado '{spl[1].Trim()}' el el Store de Certficado, asegurese que el certificado este instalado, y que el usuario que corrar el contexto de la aplicacion tenga permisos para acceder a este"));
         }
         IssuerSignKeys.Add(spl[0].Trim(), new SignatureHelper(priv, true));
     }
 }
Beispiel #2
0
        public CertificateHelper()
        {
            if (string.IsNullOrWhiteSpace(Settings.ClientName))
            {
                throw new ConfigurationException(("en", "Invalid Client line in configuration"),
                                                 ("es", "La Linea del cliente en la configuracion es invalida"));
            }

            if (string.IsNullOrWhiteSpace(Settings.CertificateName))
            {
                throw new ConfigurationException(("en", "Invalid certificate name in configuration"),
                                                 ("es", "La Linea del nombre del certificado cliente en la configuracion es invalida"));
            }

            var x509Certificate = SearchCertificate(Settings.CertificateName, Settings.CertificatePassword, Settings.CertificatePath);

            if (x509Certificate == null)
            {
                throw new CertificateException(
                          ("en",
                           $"Unable to find Certificate '{Settings.CertificateName.Trim()}' in the X509 Store, please make sure that the user using this context has security access to the certificate"),
                          ("es",
                           $"No puedo encontar el certificado '{Settings.CertificateName.Trim()}' el el Store de Certficado, asegurese que el certificado este instalado, y que el usuario que corrar el contexto de la aplicacion tenga permisos para acceder a este"));
            }

            ClientSignKeys.Add(Settings.ClientName.Trim(), new SignatureHelper(x509Certificate, true));
        }