一步一步学习IdentityServer3 (14) 启用Https

时间:2024-10-17 23:36:08

申领一个CA证书,我用了一个腾讯的免费证书night-c.cn,这是腾讯云买域名送的一个证书 是单域名,非泛域名

1:安装证书  IIS选择证书

2:将证书加载到Identityserver3中,并启用SSL

 static class Certificate
{
public static X509Certificate2 Get()
{
var assembly = typeof(Certificate).Assembly;
using (var stream = assembly.GetManifestResourceStream("OAuthWeb.IdrConfig.night-c.cn.pfx"))
{ return new X509Certificate2(ReadStream(stream),"密码");
}
} private static byte[] ReadStream(Stream input)
{
byte[] buffer = new byte[ * ];
using (MemoryStream ms = new MemoryStream())
{
int read;
while ((read = input.Read(buffer, , buffer.Length)) > )
{
ms.Write(buffer, , read);
}
return ms.ToArray();
}
}
}
 RequireSsl = true,

我在本地Host文件映射了下域名就OK了 注意https是443端口 需要开下 如下图搞定

一步一步学习IdentityServer3 (14) 启用Https