Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Bind Kestrel options to config by default #1703

Closed
danroth27 opened this issue Apr 17, 2017 · 8 comments
Closed

Bind Kestrel options to config by default #1703

danroth27 opened this issue Apr 17, 2017 · 8 comments

Comments

@danroth27
Copy link
Member

danroth27 commented Apr 17, 2017

Since config is in DI now by default we should support binding the Kestrel options to config by default (for UseKestrel()).

  "Kestrel": {
    "Endpoints": [ // Order matters!
      {
        "Address": "localhost",
        "Port": "44316",
        "Certificate": { // Implies HTTPS
          "Subject": "danroth27.com", // Pick the cert that matches the subject name with the latest expiry
          "StoreName": "My",
          "StoreLocation": "CurrentUser"
        }
      },
      {
        "Address": "localhost",
        "Port": "8080"
      },
      {
        "Address": "localhost",
        "Port": "44317",
        "Certificate": {
          "Path": "./mysslcert.pfx",
          "Password": "abc!123" // In user secrets: Kestrel:Endpoints:2:Certificate:Password
        }
      }
    ]
  }
@danroth27
Copy link
Member Author

@muratg
Copy link
Contributor

muratg commented Apr 17, 2017

👀

@danroth27
Copy link
Member Author

Or you can name your endpoints:

  "Kestrel": {
    "Endpoints": {
      "CertFromStore": {
        "Address": "localhost",
        "Port": "44316",
        "Certificate": { // Implies HTTPS
          "Subject": "danroth27.com", // Pick the cert that matches the subject name with the latest expiry
          "StoreName": "My",
          "StoreLocation": "CurrentUser"
        }
      },
      "LocalhostWithPort": {
        "Address": "localhost",
        "Port": "8080"
      },
      "CertFromFile": {
        "Address": "localhost",
        "Port": "44317",
        "Certificate": {
          "Path": "./mysslcert.pfx",
          "Password": "abc!123" // In user secrets: Kestrel:Endpoints:CertFromFile:Certificate:Password
        }
      }
    }
  }

@danroth27
Copy link
Member Author

This issue was moved to aspnet/MetaPackages#30

@davidcv5
Copy link

@danroth27 Did this change after MSBuild 2017. I've been trying the exact same setup and I can't get it to work. Tried in the following environments:

Mac OS X - dotnet version 2.1.0-preview1-006919
Mac OS X - dotnet version 2.0.0-preview2-006497
Win 10 - dotnet version 2.0.0-preview2-006497

Could you please point us in the right direction on how to use this properly. The docs at https://docs.microsoft.com/en-us/aspnet/core/security/https describe the exact same setup, but that article is from May, the same time as MSBuild2017 when you presented this feature.

Steps to reproduce:

mkdir kestrel
cd kestrel
dotnet new web

create appsettings.json with content:

{
"Kestrel": {
    "Endpoints": {
      "Localhost": {
        "Address": "127.0.0.1",
        "Port": "5001"
      }
    }
  }
}

dotnet run

Logs
Hosting environment: Production
Content root path: /Users/[user]/projects/demo
Now listening on: http://localhost:5000 <---- should be 5001
Application started. Press Ctrl+C to shut down.

Thank you!

@natemcmaster
Copy link
Contributor

This feature was cut from 2.0.0. #1886 (comment)

@davidcv5
Copy link

davidcv5 commented Jul 28, 2017

@natemcmaster thank you! I guess this should be updated. https://docs.microsoft.com/en-us/aspnet/core/security/https

@natemcmaster
Copy link
Contributor

We will :) We're working on getting our docs ready for 2.0 RTM. dotnet/AspNetCore.Docs#3815

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants