In adition to crisvdb answer, I've several information to add and is the continuation of the walktrough. I don't comment because is pretty complex comment this, but before this answer take a look to crisvdb answer first and then return to continue.
Take the "in detail" crisdb answer.
- You can make your cert in any folder, can be or can't be in the same folder of the app.
- Take openssl verify -CAfile localhost.crt localhost.crtas not optional step, mandatory. It will help.
- Do not recompile or touch the code meanwhile you are doing this, in order to get first scenario clean.
- If you run sudo update-ca-certificatesthat will answer you in wich folder the certified should be copied.
- In some distributions, as Raspbian for Raspberry Pi, CA certificates are located in /etc/ssl/certsas well as/usr/share/ca-certificates/and in some cases/usr/local/share/certificates.
- Do not copy the cert manually to trusted certs, run  sudo update-ca-certificatesafter you copy the cert in the right folder. If it doesn't work (doesn't update or add any certificate) copy it to every folder possible.
- If you use a password while making the certificate, you should use it in the  appsettings.json
- If you get this error:
Interop+Crypto+OpenSslCryptographicException: error:2006D002:BIO
routines:BIO_new_file:system lib
Take in consideration that error means "access denied". It can be because you don't have permissions or related.
7b) Could be also that the file is not found, I use the entire path in the config:
 "Path": "/home/user/www/myfolder1/myapp/localhost.pfx",
- After that, and if everything works, you could see a 500 error if you are using Apache or Apache2.
If you get the following error in the apache logs of the site:
[ssl:error] [remote ::1:yourport] AH01961: SSL Proxy requested for
yoursite.com:443 but not enabled [Hint: SSLProxyEngine] [proxy:error]
AH00961: HTTPS: failed to enable ssl support for [::1]:yourport
(localhost)
you must set in the VirtualHost the following configuration after SSLEngine On and before your ProxyPass
SSLProxyEngine on
- After that, and if everything works, you could see a 500 error if you are using Apache or Apache2.
If you get the following error in the apache logs of the site:
[proxy:error]  [client x.x.x.x:port] AH00898: Error during SSL
Handshake with remote server returned by /
[proxy_http:error] [client x.x.x.x:port] AH01097: pass request body failed to [::1]:port
(localhost) from x.x.x.x()
you must set in the VirtualHost the following configuration after SSLProxyEngine on and before your ProxyPass
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
UPDATE
If you are renovating this, and using the same names, take in consideration that you should remove your pem file from etc/ssl/certs
UPDATE 2
If it returns:
Unhandled exception. Interop+Crypto+OpenSslCryptographicException: error:2006D002:BIO routines:BIO_new_file:system lib
Check that your pfx file is on 755 permissions.
If appsettings.json seems to be don't load (on port 5000 by default or SQL or any configuration doesn't load or can't be read), take in consideration that the dotnet must be executed on the same directory where is appsettings.json