【问题标题】:How to configure signed SSL certificates with aspnet core 3.1 on hosted in Kestrel/linux如何使用托管在 Kestrel/linux 中的 aspnet core 3.1 配置签名 SSL 证书
【发布时间】:2020-12-04 16:50:14
【问题描述】:

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

我使用以下方法设置了私钥:

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

服务器模式 SSL 必须使用带有相关私钥的证书

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

【问题讨论】:

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


    【解决方案1】:

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

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

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

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

    【讨论】:

    • 谢谢甘比!效果很好
    猜你喜欢
    • 2020-05-12
    • 2021-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-21
    • 2022-07-01
    • 2019-05-08
    相关资源
    最近更新 更多