Using the BouncyCastle API I create certificates and add them to the certificate store, marking the Private Key persisted and exportable.
My key shows up in the local machine's personal
store and is a selectable option inside IIS manager, however, when I click OK to bind my certificate, I get an error dialog with the following message:-
A specified logon session does not exist. It may already have been terminated. (Exception from HRESULT: 0x80070520)
In Windows Event Viewer, the following is logged:-
A fatal error occurred when attempting to access the TLS server credential private key. The error code returned from the cryptographic module is 0x8009030D. The internal error state is 10001.
I have verified that my private key is exportable by going to Action -> All Tasks -> Export...
in Certificates MMC and can see that the radio button to export private key is not grayed out.
Suspecting that it could be a file permissions issue, I also from the MMC went to All Tasks -> Manage Private Keys
and tried setting Full Control + Read
on the application pool the site uses in IIS. Same error, in desperation, I have even tried setting it to Everyone
with no success.
I am unsure what else could be causing this issue, or what other steps I should try.
Here is a link to a pastebin of the code I am using to generate the certificate, in case it provides any useful information.
User contributions licensed under CC BY-SA 3.0