其他分享
首页 > 其他分享> > CodeGo.net>如何从SSL密钥文件创建RsaSecurityKey的实例

CodeGo.net>如何从SSL密钥文件创建RsaSecurityKey的实例

作者:互联网

我有一个RFC 7468中所述格式的RSA私钥,我正在使用的库需要一个SecurityKey实例,而构造函数似乎都没有接受这种格式的字符串,或者它的构造函数所接受的任何参数似乎都没有接受格式.

解决方法:

Found a Library that handles PEM Keys in .Net,如果同时包含DerConverter和PemUtils,则可以简单地读取文件:

RsaSecurityKey key;
using (var stream = File.OpenRead(path))
using (var reader = new PemReader(stream))
{
    key = new RsaSecurityKey(reader.ReadRsaKey());
    // ...
}

标签:net-core,rsa,c
来源: https://codeday.me/bug/20191111/2018626.html