How to get info from client certificates issued by a CA (C#, VS 2010)
Hi all,
I developed this sample some time ago: How to get info from client certificates issued by a CA (C#). The other day I tried it on a new machine with Windows 7, Visual Studio 2010 and .NET Framework 4.0, and it didn't even compile. I had to do the following to make it work:
1) Install this to be able to use certadmin.dll in a client machine:
Remote Server Administration Tools for Windows 7 with Service Pack 1 (SP1)
Or this depending on your OS version:
Microsoft Remote Server Administration Tools for Windows Vista
And turn the feature on from "Control Panel" > "Programs and Features" > "Turn Windows features on or off".
2) Generate certadminlib.dll with "tlbimp certadm.dll" and add it as a reference to the project.
3) Change this
“
CERTADMINLib.CCertViewClass
“
to this:
“
CERTADMINLib.CCertView
“
4) Add Microsoft.CSharp reference.
I hope this helps.
Regards,
Alex (Alejandro Campos Magencio)
Comments
- Anonymous
June 28, 2012
Hi, tried to post before but it might have gotten lost. I have tried the above solution but can't get it to work. I have tried with different tlbimp, different .net version and to target different platforms. But it just wont work. When i try to use any methods it gives me an error indicating that it haven't been registered. Using the remote administrative tools works just fine so it has to be something with the code when i try to use it. Any suggestions? - Anonymous
July 10, 2012
The comment has been removed - Anonymous
September 06, 2012
Some follow up:I got help from Microsoft to solve this all Credit to Helge Mahrt.If trying to run the program in any other way than x64 compile this will result in above error.So1) Compile with x64 option otherwise the program will look in C:WindowsSysWOW64 for certadmin.dll.2) It's not necessary to remove the "Class" ending, it all depends on if you choose to use the option "False" or "True" on Embed interop types for CERTADMINLibThanks