如何从 SSL 密钥文件创建 RsaSecurityKey 实例
How do you create an instance of RsaSecurityKey from a SSL key file
我有一个 RSA 私钥,其格式如 RFC 7468 所述,我正在使用的库需要 SecurityKey
none 构造函数的实例似乎接受字符串在这种格式中,它的构造函数的任何接受的参数似乎都接受这种格式。
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());
// ...
}
我有一个 RSA 私钥,其格式如 RFC 7468 所述,我正在使用的库需要 SecurityKey
none 构造函数的实例似乎接受字符串在这种格式中,它的构造函数的任何接受的参数似乎都接受这种格式。
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());
// ...
}