Пример #1
0
 public static DatosCert GetDatosCert(byte[] cer)
 {
     if (cer != null)
     {
         try
         {
             X509Certificate cert = new X509Certificate();
             cert.Import(cer);
             string        resultsTrue = cert.ToString(true);
             List <string> separacion  = new List <string>();
             separacion = resultsTrue.Split(new string[] { "\r\n\r\n" }, StringSplitOptions.None).ToList();
             DatosCert datos = new DatosCert();
             datos.Sujeto_Nombre = separacion[0];
             datos.Sujeto_Id     = separacion[0];
             datos.Emisor_Nombre = separacion[1];
             datos.Emisor_Id     = separacion[1];
             datos.Serie         = Utilerias.ConvertHex(cert.GetSerialNumberString());
             return(datos);
         }
         catch (Exception exe)
         {
             throw exe;
         }
     }
     else
     {
         throw new Exception("El archivo no se encontro");
     }
 }
Пример #2
0
 public void ReadPublic()
 {
     try
     {
         System.IO.StringWriter stWrite = new System.IO.StringWriter();
         Certificado = new X509Certificate2(CertificateBytes);
         Org.BouncyCastle.X509.X509Certificate cert = DotNetUtilities.FromX509Certificate(Certificado);
         PubliceyParameter = cert.GetPublicKey();
         MemoryStream ms     = new MemoryStream();
         TextWriter   writer = new StreamWriter(ms);
         Org.BouncyCastle.OpenSsl.PemWriter pmw = new Org.BouncyCastle.OpenSsl.PemWriter(stWrite);
         pmw.WriteObject(PubliceyParameter);
         stWrite.Close();
         PublicKeyRSA = stWrite.ToString();
         Datos        = DatosCert.GetDatosCert(CertificateBytes);
     }
     catch (Exception exe)
     {
         throw new Exception(Resource.ErrorCertificado);
     }
 }