简体   繁体   English

如何从SSL密钥文件创建RsaSecurityKey实例

[英]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: 找到一个在.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.

相关问题 C#:如何将私钥加载到 .net 框架/标准中的 RsaSecurityKey 中? - C#: How to load a private key into RsaSecurityKey in .net Framework/Standard? 如何从 Excel 电子表格创建一个 .xslt 文件? - How do you create an .xslt file from an Excel spreadsheet? 如何从文本文件创建类的实例? - How to Create an Instance of a Class from a Text File? c# 如何将 JWK 转换为 RsaSecurityKey - c# how to convert a JWK to a RsaSecurityKey 如何从ServiceInstanceListener构造函数外部访问StatelessServiceContext实例 - How do you access the StatelessServiceContext instance from outside the ServiceInstanceListener constructor 当您不想公开类的实例时,如何创建模拟/替代? - How do you create a mock/substitute when you don't want to expose an instance of a class? 如何使用 C# 通过读取另一个 XML 文件来创建 XML 文档? - How do you create XML document from reading another XML file using C#? 您如何验证数字证书SSL? - how do you validate the digital certificate SSL? 您如何从剃刀视图页面引用外键? - How do you reference a foreign key from a razor view page? 我如何创建将从.csv文件中读取键和值的AC#词典 - How do i create a c# dictionary that will read in key and values from .csv file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM