linux - 如何在 Kestrel/linux 托管的 aspnet core 3.1 上配置签名 SSL 证书

标签 linux asp.net-core ssl web-hosting

我设法获得了 LetsEncrypt 签名的证书,以便在主机上正确为我的域启用 SSL。现在我不明白如何将它绑定(bind)到我在 ubuntu 上运行的应用程序:

我使用以下内容来设置私钥:

webBuilder.UseKestrel((hostingContext, options) =>
{
   options.ListenAnyIP(443, loptions => loptions.UseHttps("/etc/letsencrypt/live/mydomain.com/privkey.pem"));
});

The server mode SSL must use a certificate with the associated private key

我不清楚如何绑定(bind)公钥和私钥并在不使用apache或nginx的情况下远程使用它。

最佳答案

您首先需要使用OpenSSL将您的私钥证书转换为pfx证书:

openssl pkcs12 -inkey privatekey.pem -in mycert.cert -export -out mycertificate.pfx

然后,您可以在 Kestrel 的 appsettings.json 文件中以这种方式使用它:

"Kestrel": {
    "EndPoints": {
      "HttpsDefaultCert": {
        "Url": "https://*:443"
      },
      "Http": {
        "Url": "http://*:80"
      }
    },
    "Certificates": {
      "Default": {
        "Path": "mycertificate.pfx",
        "Password": "MyCertificatePassword"
      }
    }
  }

关于linux - 如何在 Kestrel/linux 托管的 aspnet core 3.1 上配置签名 SSL 证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65147492/

相关文章:

linux - 如何在 Linux 上确定共享库依赖路径?

asp.net-core - 了解 ASP.NET Core 补丁版本前滚

python - brew 安装 python3 后出现 SSL 错误

ssl - 在 Amazon EC2 上运行的 Java 应用程序 - 将 http 重定向到 https

linux - _mm_clflush 真的会刷新缓存吗?

linux - 简单的Qt5应用程序在终端上输出空白行

Linux虚拟键盘和evdev

c# - 如何生成 appsettings.<EnvironmentName>.json 文件?

c# - DynamicRouteValueTransformer 更改值不会产生任何影响

php - Gravatar 不再通过 https 工作