Click here to Skip to main content
15,904,653 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi dear developers can any one help me ?

I have a link like this:

ldap://annuaire.xxx.fr/cn=amo_pj.test@test.xx.fr,ou=AC-FACTURATION,ou=AC-SV-VITALE-2034,o=sv-vitale,c=fr?userCertificate;binary

I can paste this link on any navigator, get the certificate from the server, save it to disk and then install it in localmachine store.

But I would like to do it by program (either using c++ or c#)

What I have tried:

1) I tried this in c#

public static void InstallCertificate()
{
string address = @"ldap://annuaire.xxx.fr/cn=amo_pj.test@test.xx.fr,ou=AC-FACTURATION,ou=AC-SV-VITALE-2034,o=sv-vitale,c=fr?userCertificate;binary";

ICertRequest3 objRequest = new CCertRequest();

string rootCert = objRequest.GetCACertificate(0, address, 0);


byte[] buffer = Encoding.UTF8.GetBytes(rootCert);

// installing
var store = new X509Store("Root", StoreLocation.LocalMachine);
store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadWrite);
var root = new X509Certificate2(buffer);
store.Add(root);
}

Error com:
CCertRequest::GetCACertificate: Le serveur RPC n’est pas disponible. 0x800706ba (WIN32: 1722)

2) I tried this one using openssl

OpenSSL> s_client -connect ldap://annuaire.xxx.fr:636 -showcerts

getservbyname failure for //annuaire.xxx.fr:636

OpenSSL> s_client -connect annuaire.xxx.fr:636 -showcerts
connect: No such file or directory
connect:errno=0
error in s_client
Posted
Comments
Gautham Prabhu K 9-Mar-16 6:55am    
Does your program have proper authorization to access internet?
KarstenK 10-Mar-16 2:18am    
Tip: For certificate installation the running process must be an administrator.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900