2017-06-16 71 views
0

我有一个在RFC 7468中所述格式的RSA私钥和我正在使用的库需要一个SecurityKey实例没有一个构造函数似乎接受字符串这种格式,也没有任何它的构造函数接受的参数似乎接受这种格式。如何从SSL密钥文件创建RsaSecurityKey实例

+0

任何代码,好吗? – VMAtm

+0

'SecurityKey'不是一个.NET框架类型。所以也许你应该说你正在尝试使用的库? – bartonjs

回答

0

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()); 
    // ... 
}