如何在C#中导入PKCS#8 RSA私钥(由OpenSSL创建) [英] How to import PKCS#8 RSA privateKey (created by OpenSSL) in C#
问题描述
我正在尝试寻找一种方法,以在不使用外部库的情况下读取使用C#中的OpenSSL PKCS#8 RSA创建的私钥.
I'm trying to find a way to read a privateKey created using OpenSSL PKCS#8 RSA in C# without use external library.
有人知道我该怎么做吗?
Does Someone know how i can do this?
推荐答案
通过外部库使用 进行此操作的最简单方法是使用(免费)只需几行代码,如果您愿意为其余的库支付149美元左右,还将使处理一般的加密概念也变得更加容易.
The easiest way to do this with an external library, is using the (free) Chillkat Public / Private Key Component: using that, importing the key can be done using just a few lines of code and if you're willing to pay the $149 or so for the rest of the library, it will make dealing with general crypto concepts a lot easier as well.
与常规的Microsoft .NET Framework不同,Mono项目确实似乎具有完整的C#源代码可用.如果您绝对不能依赖外部库,这可能是一个起点,假设与Mono代码相关的(LGPL 2.0)许可证对您有效...
And unlike the regular Microsoft .NET Framework, the Mono project does seem to have a PKCS8 implementation for which the full C# source is available. This may be suitable as a starting point in case you absolutely cannot rely on external libraries, assuming the (LGPL 2.0) license associated with the Mono code works for you...
最后, PKCS#8格式不是太难解析了,RSA/DSA密钥对对象按照
Finally, the PKCS #8 format is not too difficult to parse, and the RSA/DSA key pair objects are as per PKCS #11 and relatively easy to convert to a .NET X509Certificate once you figure out where all the bits go -- I actually did this in VB.NET a while ago, but unfortunately am not able to share that code.
这篇关于如何在C#中导入PKCS#8 RSA私钥(由OpenSSL创建)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!