Creating self-signed certificate programmatically using "CERTENROLLLib" in Windows Server 2012 R2

0

I am creating a self-signed certificate for converting IIS web-ste from http to https. Essentially, I am using the code suggested here. It works perfectly fine with Windows server 2019. However, when the same code is deployed in Windows Server 2012 R2, i am getting the error around the code -

CX509PrivateKey privateKey = new CX509PrivateKey();

I am getting the exception, which is like this - *"While performing the operation create encountered an Exception:

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)"*

I tried the solutions suggested here, but nothing works for me.

I am using .Net Core 5.0 for creating the web site. In fact, using "CERTENROLLLib" from creating the self signed certificate and deploying it to IIS web site was the only solution which worked for me. However, when the website is created in Windows Server 2012 R2, I got this error.

c#
com-interop
windows-server-2012-r2
asp.net-core-5.0
self-signed-certificate
asked on Stack Overflow Apr 28, 2021 by user1748546 • edited Apr 29, 2021 by user306038-----

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0