gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 22:36:07 24 4
gpt4 key购买 nike

我设法获得了一个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 的情况下远程使用它。

最佳答案

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

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


然后,您可以在 中以这种方式使用它。 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com