I’m trying to generate a self-signed SSL certificate from this .cnf file:
[req]
default_bits = 2048
distinguished_name = req_distinguished_name
req_extensions = req_ext
x509_extensions = v3_req
prompt = no
[req_distinguished_name]
countryName = BR
stateOrProvinceName = SC
localityName = PB
organizationName = MyCompany
CN = 20.14.3.12 // My Local IPv4
[req_ext]
subjectAltName = @alt_names
[v3_req]
subjectAltName = @alt_names
[alt_names]
IP.1 = 20.14.3.12 // My Local IPv4
To create the .key
and .crt
file, I’m using openssl:
openssl req -x509 -days 36500 -newkey rsa:2048 -keyout key.key -out cert.crt -config san.cnf
I’m also adding the .crt
file in Microsoft Management Console
, in Root Certification Authorities
folder
enter image description here
In my .NET 8 code, I’m adding the following Kestrel
tag in appsettings.json
:
"Kestrel": {
"Endpoints": {
"HttpsInlineCertAndKeyFile": {
"Url": "https://20.14.3.12:7142",
"Certificate": {
"Path": "./Utils/Certificates/cert.crt", // the path is correct
"KeyPath": "./Utils/Certificates/key.key",
"Password": "mypassword"
}
}
}
}
My application listen to https://20.14.3.12:7142 and when I try to open swagger, for example, I see this:
enter image description here
PS: I’ve tested it using localhost
instead of my ip and all works fine, the only change that I’ve make was to change the IP.1
in .cnf
file for DNS.1
Guilherme Santana is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.