Check certificate X509certificate2

Asked

Viewed 170 times

-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 any way to do this?

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
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.