Import certificate with private key programmatically

后端 未结 3 1671
青春惊慌失措
青春惊慌失措 2021-01-31 22:12

I\'m trying to use the HttpListener class in a C# application to have a mini webserver serve content over SSL. In order to do this I need to use the httpcfg tool. I have a .pf

3条回答
  •  有刺的猬
    2021-01-31 23:13

    Ok, I figured it out. It had to do with the key storage parameters for the certificate object. For anyone else that runs into this problem, make sure you construct your X509Certificate2 objects that you are adding to the store using the X509KeyStorageFlags.PersistKeySet and X509KeyStorageFlags.MachineKeySet flags. This will force the private key to persist in the machine key set location which is required by HttpApi (HttpListener wraps this).

提交回复
热议问题