RSACryptoServiceProvider 和 openSSL 之间的互操作性
我已经使用 .NET 类 RSACryptoServiceProvider
来获取密钥对:
using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider())
{
File.WriteAllText ("PublicKeyOnly.xml", rsa.ToXmlString (false));
File.WriteAllText ("PublicPrivate.xml", rsa.ToXmlString (true));
}
现在,我想将其与 openSSH 一起使用,但密钥格式看起来并不相似。 有谁知道如何将公钥和私钥转换为 openSSH 可以使用的文件?
谢谢!
I've used the .NET class RSACryptoServiceProvider
to get a keypair:
using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider())
{
File.WriteAllText ("PublicKeyOnly.xml", rsa.ToXmlString (false));
File.WriteAllText ("PublicPrivate.xml", rsa.ToXmlString (true));
}
Now, I would like to use this with openSSH, but the key format looks nothing alike.
Does anyone know how to convert both the public and private keys to files that openSSH can use?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我确实需要实现 Openssl 与 RSACryptoServiceProvider 的互操作性,以便我可以实现软件许可证密钥系统 (参考)。
我需要能够使用 openssl 在 Linux 中创建私钥和公钥,以便以后可以将它们用于 PHP Web 应用程序中的许可证管理。然而,也可以将它们用作 VB.Net 应用程序中 RSA 签名许可系统的基础。
经过一周的搜索,我最终发现这是完全可能的,所以我想我会分享它。
在 Linux(或任何其他有用的操作系统)上启动并使用 openssl 创建私钥 (private.pem)、公钥 (public.pem)、证书 (certificate.crt) 和个人信息交换文件 (certificate.pfx) )。不用担心 CN 和 emailAddress 字段,证书和 pfx 文件仅用作将公钥或私钥获取到 RSACryptoServiceProvider 对象中的工具。
现在将私钥放入代码中:
如果您需要私钥或公钥,请尝试以下操作:
将公钥放入代码中:
如果您需要公钥,请尝试以下操作:
更多内容即将到来......
I really needed to achieve Openssl interoperability with RSACryptoServiceProvider, so that I could implement a software licence key system (Ref).
I needed to be able to create the private and public keys in Linux using openssl so that they could later be used for license management in a PHP web application. Yet, also use them as the basis of an RSA signature license system in a VB.Net applciation.
After a week of searching, I eventually discovered that this is perfectly possible, so I thought I would share it.
Start on Linux (or any other useful OS) and use openssl to create a private key (private.pem), a public key (public.pem), a certificate (certificate.crt) and a Personal Information Exchange File (certificate.pfx). Don't worry about the CN and emailAddress fields, the certificate and pfx files are only being used as a vehicle to get the public or private key into the RSACryptoServiceProvider object.
Now to get the private key into the code:
If you need the private key or public key try this:
To get the public key into the code:
If you need the public key try this:
More to come .....
这篇关于使用 OpenSSL 和 RSACryptoServiceProvider 的博客文章指出这是可能的,但作者最终使用 Chilkat RSA 库最终在 C# 内与 OpenSSL 进行互操作。 .NET 世界不支持 PEM 格式,因此您可以使用 JavaScience 中名为 OpenSSLKey.cs 的库;然而,正如博客文章的作者提到的,他们因此遇到了问题(引用):
所以我建议您使用 Chilkat RSA 库。
This blog post on using OpenSSL and RSACryptoServiceProvider states that it is possible, but the author ended up using the Chilkat RSA Library to ultimately interoperate with OpenSSL from within C#. The PEM format is not supported in the .NET world so you could use this library from JavaScience called OpenSSLKey.cs; however, as the author of the blog post mentions they had problems due to this (quoted):
So I recommend you go with the Chilkat RSA library.