How to Export Private Key For ECDiffieHellmanCng

前端 未结 2 1370
故里飘歌
故里飘歌 2021-01-13 05:07

I am trying to export the keys from a new instance of a ECDiffieHellmanCng object so I can create an instance of it later with the same keys. But I am getting an er

2条回答
  •  梦毁少年i
    2021-01-13 05:21

    I believe you are specifying the wrong BLOB format. Try:

    var privateKey = ecdh.Key.Export(CngKeyBlobFormat.Pkcs8PrivateBlob);
    

    If that fails, you need to set up a key policy that allows private key export. See this answer: https://stackoverflow.com/a/10274270/2420979 for more details on your problem.

提交回复
热议问题