Check certificate X509Certificate2

-1

Is there any way I can verify that the A3 certificate is connected to the computer? Some kind of validation for example. I work with an application that makes use of A3 certificate, but I do not do this validation of whether the certificate is connected or not, does anyone know of any way to do this?

    
asked by anonymous 10.05.2018 / 20:26

1 answer

0
//Busca Certificado
var certificado = new X509Certificate2(caminhoCertificado);

//Instancia o registro de certificados na maquina local
var store = new X509Store(StoreName.Root, StoreLocation.LocalMachine);

//Abre em modo de leitura
store.Open(OpenFlags.ReadOnly);


var certificados = store.Certificates.Find(
    X509FindType.FindBySubjectName, //Criterio de busca
    certificado.SubjectName, //Valor para busca
    false);//Os inválidos também

if (certificados != null && certificados.Count > 0)
{
   //Certificado Já instalado
}
    
12.05.2018 / 01:12