Import of Pkcs#8 encrypted private key using .NET

有些话、适合烂在心里 提交于 2020-05-30 08:00:08

问题


I want to import (RSA and ECDsa) private keys from pkcs8 files (-----BEGIN ENCRYPTED PRIVATE KEY-----).

This question How to import PKCS#8 RSA privateKey (created by OpenSSL) in C# has been answered, but the only acceptable solution for me is to implement pkcs8 parser which I want to avoid to as well as using of 3rd party libraries (beside the Chillkat there is also BouncyCastle and its PemReader) as well as pinvoke and NCryptImportKey (mentioned here: Importing PKCS#8 encrypted key to RSACng?) (I didn't go this way so far, so I'm not sure it is suitable. Is it?).

I would expect something like CngKey key = CngKey.Import(bytes, CngKeyBlobFormat.Pkcs8PrivateBlob, password) unfortunately Import method supports import of unencrypted keys only (-----BEGIN PRIVATE KEY-----).

Is there any other way to get those keys using .NET version: 4.7.2?

Thanks.

来源:https://stackoverflow.com/questions/52987169/import-of-pkcs8-encrypted-private-key-using-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!