Hola a todos soy de nuevo..
Ahora lo que quiero hacer es que cuando inicie un programa realize lo siguiente.
1) Verfique si existe un cerficado instalado,
2) si no existe importarlo. como puede hacerlo.
gracias por la ayuda.
| ||||
Respuesta: Importar un cerficado mediante codigo en c# Dentro del certificado dice que tiene como proposito: Todas las directivas de emision Todas las directivas de la Aplicacion. y la extencion es .cer y se debe importar dentro del administrador de certificados "certmgr.exe" en Certificados - Usuario actual Entidades de certificación raíz de confianza Certificados gracias |
| ||||
![]() Hola Yo..... Al fin lo encontreeeeeeeeeeee..... se hace asi.
Código:
no olvidarse del losclass Program { /// <summary> /// The main entry point. /// </summary> [STAThread] static void Main( string[] args ) { try { X509Store serviceRuntimeUserCertificateStore = new X509Store(StoreName.Root); string baseDir = AppDomain.CurrentDomain.BaseDirectory; string certificateFolder = "c:\\"; string certPath = Path.Combine(baseDir, certificateFolder); string certificateFile = "user-calist.cer"; string certificatePassword = "somePassword"; string certificateLocation = certPath + certificateFile; InstallCertificate(certificateLocation, certificatePassword); } catch (Exception ex) { Console.WriteLine(ex); } } private static void InstallCertificate(string certificatePath, string certificatePassword) { try { var serviceRuntimeUserCertificateStore = new X509Store(StoreName.Root); serviceRuntimeUserCertificateStore.Open(OpenFlags.ReadWrite); X509Certificate2 cert= null; try { cert = new X509Certificate2(certificatePath, certificatePassword); } catch (Exception ex) { Console.WriteLine("Failed to load certificate " + certificatePath); //throw new DataException("Certificate appeared to load successfully but also seems to be null.", ex); } serviceRuntimeUserCertificateStore.Add(cert); serviceRuntimeUserCertificateStore.Close(); } catch (Exception) { Console.WriteLine("Failed to install {0}. Check the certificate index entry and verify the certificate file exists.", certificatePath); } } } using System; using System.IO; using System.Security.Cryptography.X509Certificates; |