我设法获得了 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/