【发布时间】:2017-03-15 07:29:54
【问题描述】:
我正在尝试使用自签名证书来配置 IdentityServer3, 我使用 openssl 创建了一个 x509 证书,如下所示: openssl req -x509 -sha256 -days 365 -key key.pem -in csr.csr -out certificate.pem 然后使用以下方法合并密钥和证书: pkcs12 -export -in my-cert.pem inkey my-key.pem -out xyz-cert.pfx 然后我将 xyz-cert.pfx 的内容转换为存储在 web.config 中的密钥中的 Base64String,然后尝试使用证书实例化 X509Certificate2,如下所示:
var certificate = Convert.FromBase64String(ConfigurationManager.AppSettings["SigningCertificate"]);
var options = new IdentityServerOptions
{
SigningCertificate = new X509Certificate2(certificate, ConfigurationManager.AppSettings["SigningCertificatePassword"]),
RequireSsl = false, // DO NOT DO THIS IN
Factory = factory
};
我不知道我哪里弄错了。 感谢您的帮助
【问题讨论】:
标签: c# .net cryptography asp.net-web-api2 x509certificate2