2

如何将 certadm.dll 导入托管项目并使用 RevokeCertificate 方法?我尝试将其添加为参考,但由于它不是程序集或 COM 对象而出现错误。

有任何想法吗?

更新:我已经尝试过regsvr32 c:\certadm.dll并收到以下错误: LoadLibrary("c:\certadm.dll") failed - 找不到指定的过程。

4

2 回答 2

2

我知道这是一个非常古老的问题,但我找不到任何在 c# 中使用 ICertAdmin2::RevokeCertificate 的示例。我认为在这里写exaple很有用。

1 添加 certadmin 库

在此处输入图像描述

2 使用此代码

public static void RevokeCert(string connection,string serial)
{
    //connection= "192.168.71.128\\My-CA"
    //serial = "614870cd000000000014"

    const int CRL_REASON_UNSPECIFIED = 0;

    CERTADMINLib.CCertAdmin _admin = null;
    try
    {
        _admin = new CCertAdmin();
        _admin.RevokeCertificate(connection, serial, CRL_REASON_UNSPECIFIED, DateTime.Now);
    }
    finally
    {
        if (_admin != null)
            Marshal.FinalReleaseComObject(_admin);
    }
}
于 2014-10-27T10:55:41.510 回答
0

You first need to register the COM server using regsvr32 before it will be available to be added as a reference in Visual Studio.

e.g.,

regsvr32 certadm.dll
于 2009-08-04T14:04:30.190 回答