在 Windows Server 2012 R2 中使用“CERTENROLLLib”以编程方式创建自签名证书

问题描述

我正在创建一个自签名证书,用于将 IIS web-ste 从 http 转换为 https。本质上,我正在使用建议的代码 here。它与 Windows Server 2019 完美配合。但是,当在 Windows Server 2012 R2 中部署相同的代码时,我收到了有关代码错误 -

CX509PrivateKey privateKey = new CX509PrivateKey();

我收到了异常,就像这样 - *"在执行创建操作时遇到异常:

Unable to cast COM object of type 'CERTENROLLLib.CX509PrivateKeyClass' to interface type 'CERTENROLLLib.IX509PrivateKey2'. This operation Failed because the QueryInterface call on the COM component for the interface with IID '{728AB362-217D-11DA-B2A4-000E7BBB2B09}' Failed due to the following error: No such interface supported (0x80004002 (E_NOINTERFACE)).
at System.StubHelpers.StubHelpers.GetCOMIPFromrCW(Object objSrc,IntPtr pCPCMD,IntPtr& ppTarget,Boolean& pfNeedsRelease)
at CERTENROLLLib.CX509PrivateKeyClass.set_ProviderName(String pValue)"*

我尝试了 here 建议的解决方案,但没有任何效果

我正在使用 .Net Core 5.0 创建网站。事实上,使用 "CERTENROLLLib" 创建自签名证书并将其部署到 IIS 网站是唯一对我有用的解决方案。但是,在 Windows Server 2012 R2 中创建网站时,出现此错误

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)