2

动机

  • 我希望能够从本地计算机上的 Windows CA 检索和查看证书。我不想访问机器的浏览器密钥库,而是 Windows CA(Windows 证书颁发机构(服务))。

  • 我想在 C#-Code 中执行此操作。

到目前为止我的调查
我发现了几个使用以下行的示例:

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

我想我能够使用这条线和 ICertView2 结构,我达到了我的目标。如果将此行写入我在 Visual Studio 中的 C#-Code 中,它会告诉我,它不知道 ICertView2 和 CERTADMINLib。因此,如果再次搜索 Web 并发现我需要导入参考。我需要 COM 库 certadmin.dll,幸运的是它存在于我的 C:\Windows\System32 文件夹中。
所以我尝试在Solutionexplorer->Project->References->Add Reference->COM 上添加参考。但它没有在那里列出,只有一个外观相似的库,称为“ CertCli 1.0 类型库”。我添加了这个并且还能够输入

using CERTCLIENTLib;

但不幸的是,所需的“ ICertView2 ”类不在其中。如果我输入

    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.

4

1 回答 1

4

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

于 2012-08-21T11:12:57.380 回答