问题
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