I can do it with OpenSSL, but need to deploy this self signed certificate to many PCs, so that the web browser can communicate to a localhost executable. I can't ask each and every PC to install openssl.
Here is what I did:
In powershell
New-SelfSignedCertificate -CertStoreLocation Cert:\LocalMachine\My -DnsName "localhost" -FriendlyName "localhost" -NotAfter (Get-Date).AddYears(10)
Launch Manage computer certificates
Navigate to Certificates - Local Computer > Personal > Certificates
to find your newly created certificate.
Copy the certificate and paste it into Trusted Root Certification Authorities > Certificates
.
Then export the certificate with private key to a pfx file (example: localhost.pfx
)
The setup
services.AddHttpsRedirection(options => { options.HttpsPort = Port; });
app.UseHttpsRedirection();
Question: how can I load the PFX into my Dotnet Core 8 Minimal API app?
As far as I know there is no difference in this regard between MVC and minimal API. Overall check this link and find "Specify HTTPS using a custom certificate" section.