[英]C#: How to load a private key into RsaSecurityKey in .net Framework/Standard?
[英]How do you create an instance of RsaSecurityKey from a SSL key file
我有一個RSA私鑰,其格式如RFC 7468所述,我正在使用的庫需要一個SecurityKey
實例,沒有一個構造函數似乎接受這種格式的字符串,也沒有任何接受的參數為它的構造函數似乎接受這種格式。
找到一個在.Net中處理PEM密鑰的庫 ,如果同時包含DerConverter和PemUtils,您只需讀取該文件:
RsaSecurityKey key;
using (var stream = File.OpenRead(path))
using (var reader = new PemReader(stream))
{
key = new RsaSecurityKey(reader.ReadRsaKey());
// ...
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.