Question

Motivation:

  • I want be able to retrieve and view Certificates from a Windows CA on a local Machine. I don't want to access the Browser-Keystores of the Machine, but the Windows CA (Windows Certifcate Authority (Service)).

  • I want to to do this in C#-Code.

My Investigation so far:
I found several Examples that are using the following line:

ICertView2 certView = new CERTADMINLib.CCertView();
...

I think i'm able to use this line and the ICertView2 Structure, i reached my Goal. If a write this Line into my C#-Code in Visual Studio, it says to me, that it don't know ICertView2 and CERTADMINLib. So if searched the Web again and found out the i need to import a Reference. I need the COM Library certadmin.dll, that fortunately exists in my C:\Windows\System32 Folder.
So i tried to add the Reference over the Solutionexplorer->Project->References->Add Reference->COM. But it is not listed there, only a similar looking Library called "CertCli 1.0 Type Library". I added this and also was able to type an

using CERTCLIENTLib;

but unfortuneatly, the needed "ICertView2" Class is not in there. If i type

    using CERTADMINLib;

that should be typed in order to be able to use the ICertView2, Visual Studio says to me, that it also don't know "CERTADMINLib".

Further i found hints on the net, that one need to register the certadm.dll beforehand, in order to make it available in Visual Studio. I tried to register the dll-File, but it doesn't work.

If i invoke the following Command:

C:\Windows\System32>regsvr32.exe C:\Windows\System32\certadm.dll

and get a Dialogbox telling me the following:
'Error while loading the Module "C:\Windows\System32\certadm.dll". ... The specified Module could not be found.'

The Version of certadm.dll ist "5.2.3790.3959". I'm using "Windows 7 Enterpise SP1".

Can you tell me, how i'm able to register and futher make the appropriate Reference available in Visual Studio?

If i've forgotten further Information, please let me know, so i can add them.

Was it helpful?

Solution

Microsoft changed much from XP to Win7. To be able to reference it you will have to tlbimp certadm.dll. Tlbimp.exe can be found in your .NET SDK's and such. Then you will have to import this library in your .NET solution. Although i have to warn you, i have not mangaged to get any code working in Win7 that works in XP.

You can also look at this link: http://blogs.msdn.com/b/alejacma/archive/2012/04/04/how-to-get-info-from-client-certificates-issued-by-a-ca-c-vs-2010.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top