c # - x509 certificate does not recognize it in windows server 2008 R2

0

I'm trying to access the certificate store on a 2008 R2 server and it says

clientCertStore.Certificates.Count = 0

The same request with the same certificate in my localhost if you return it to me, the only difference is that my PC is a W7.

The installation of the certificate has been done in the same way on both machines, with an exportable key and in the Personal store.

I do not know if it will have to do, but the certificate is expired, but as I say, on my PC if you return it to me.

private X509Certificate2 Certificate(string nif) 
{
    X509Certificate2 cert = null;
    X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser); 
    store.Open(OpenFlags.ReadOnly); 
    X509CertificateCollection certs = store.Certificates; 
    int c = certs.Count; 
    foreach (X509Certificate2 cert_aux in certs) 
    { 
        if (cert_aux.SubjectName.Name.Contains(nif.ToUpper())) 
        {
            cert = cert_aux; break; 
        }
    }

    store.Close(); 
    return cert;
}
    
asked by Mariajo 24.03.2017 в 11:23
source

1 answer

0

the warehouse you're looking for is the one of the user, not the one of the machine. Try using StoreLocation.LocalMachine If you execute

You choose Files/Add Remove Snap-in and choose Certificates

You get the option to choose the warehouse. If you choose My user account , the certificates that you install will only be available to the user with whom you have identified yourself. If you choose Computer account you will have them available for all users identified in the machine (choosing StoreLocation.LocalMachine )

    
answered by 28.03.2017 / 15:00
source