更新时间:2021-12-29 23:10:18
PowerShell中的等效代码。看来有时私钥刚好消失了。我使用Process Monitor,你可以看到正在删除的密钥文件。
I had the same issue using the equivalent code in PowerShell. It appears that sometime the private key just disappears. I used Process Monitor and you can see the key file being deleted.
我解决这个问题的方法是添加 X509KeyStorageFlags.PersistKeySet
到X509Certificate2构造函数。
The way I solved this was to add X509KeyStorageFlags.PersistKeySet
to the X509Certificate2 constructor.