我按照本教程创建了自签名 SSL 证书: https://devblogs.microsoft.com/aspnet/configuring-https-in-asp-net-core-across- different-platforms/
我正在使用Linux
Ubuntu 16.04 LTS
这是
ASP.NET 5
应用程序,我正在 docker
中运行它。
这就是步骤。我创建了文件 https.config
[ req ]
default_bits = 2048
default_md = sha256
default_keyfile = key.pem
prompt = no
encrypt_key = no
distinguished_name = req_distinguished_name
req_extensions = v3_req
x509_extensions = v3_req
[ req_distinguished_name ]
commonName = "localhost"
[ v3_req ]
subjectAltName = DNS:localhost
basicConstraints = critical, CA:false
keyUsage = critical, keyEncipherment
extendedKeyUsage = critical, 1.3.6.1.5.5.7.3.1
然后生成私钥:
openssl req -config https.config -new -out csr.pem
然后创建证书
openssl x509 -req -days 365 -extfile https.config -extensions v3_req -in csr.pem -signkey key.pem -out https.crt
最终生成pfx文件:
openssl pkcs12 -export -out https.pfx -inkey key.pem -in https.crt -password pass:mypassword
我通过位置和密码向 Kestrel 提供有关证书的信息,但密码检查失败,尽管密码没问题。我认为它加载了证书,因为当我放置文件的另一个路径时,我收到另一个错误。
sudo docker run -p 50205:443 -e "ASPNETCORE_URLS=http://+:80;https://+:443" -e "ASPNETCORE_Kestrel__Certificates__Default__Path=/https/https.pfx" -e "ASPNETCORE_Kestrel__Certificates__Default__Password=mypassword" -v /home/vlado/Desktop/https.pfx:/https/https.pfx 622
我遇到了同样的问题。就我而言,这是由密码中的特殊字符被解释为转义序列引起的。 我通过为证书设置不包含特殊字符的密码来解决这个问题。