简体   繁体   中英

How do you create an instance of RsaSecurityKey from a SSL key file

我有一个RSA私钥,其格式如RFC 7468所述,我正在使用的库需要一个SecurityKey实例,没有一个构造函数似乎接受这种格式的字符串,也没有任何接受的参数为它的构造函数似乎接受这种格式。

Found a Library that handles PEM Keys in .Net , If you include both DerConverter and PemUtils you can simply read the file:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM