ASP.Net Core application service only listening to Port 5000 on Ubuntu

那年仲夏 提交于 2019-12-03 15:35:55

Finally i figured out the issue. The issue is that a developer ssl certificate is installed with dotnet SDK with the name localhost. In case of Ubuntu the certificate is located at /home/{user name} /.dotnet/corefx/cryptography/x509stores/my

Kestrel just searches in the home directory of executing user, which does not exists for 'www-data', hence it couldn't locate the development certificate. Due to which it doesn't bind to default https port.

To get it working, i first converted my existing certificate in PEM (.crt) format to PKCS12 (.pkf) using OpenSSL. Below is the command.

sudo openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile more.crt

Then i needed to specify this certificate to Kestrel server, using appsettings.json file. Below is how the file looks now :

{
  "ConnectionStrings": {
    "PostgresConnection": "Host=localhost; Database=postgres; Username=postgres; Password=xyz123"
  },
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Warning"
    }
  },

  "Kestrel": {
    "Endpoints": {
      "HTTPS": {
        "Url": "https://localhost:5001",
        "Certificate": {
          "Path": "/etc/ssl/certs/<certificate.pfx>",
          "Password": "xyz123"
        }
      }
    }
  }
}

Then you need to add www-data user to ssl-certs group. below is command line :

sudo usermod -aG ssl-cert www-data
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!