Custom HTTPS Dev Environment using .NET Core, Kestrel & certificates

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ก.ย. 2024
  • In this step by step tutorial I take you through how to set up a “custom” domain using: .NET Core, Kestrel webserver, self-signed certificates and more.
    Level: Beginner / Intermediate
    📕 My Book: www.apress.com...
    🤗 Patreon Site (Exclusive Member Benefits!): / binarythistle
    💻 Blog Article: dotnetplaybook...
    💻 Code on GitHub: github.com/bin...
    🔒 HTTPS Article: www.cloudflare...
    🔑 Public & Private Keys: / explaining-public-key-...
    ⏲️ Time Codes ⏲️
    -------------------------------
    INTRODUCTION
    - 2:21 Course Overview
    - 5:46 Demo
    - 6:27 Tooling
    HTTPS OVERVIEW
    - 6:49 What is HTTPS, SSL & TLS?
    - 7:46 Certificate & Authorities Overview
    - 9:44 What does a certificate contain?
    - 10:30 Public & Private Key Overview
    - 11:48 HTTPS How it Works (Interaction Diagram)
    LOCALHOST SET UP
    - 14:37 Scaffold Up our API
    - 19:25 Generating a Local Dev Certificate
    - 22:37 The need for a custom domain
    CUSTOM DOMAIN PART 1
    - 23:56 Update HOSTS File
    - 27:02 Host name resolution order
    - 28:15 Create our Self-Signed Certificate
    - 35:00 Import Certificate into Trusted Root
    CUSTOM DOMAIN PART 2
    - 36:58 - User Secrets Overview
    - 38:30 - Configure User Secrets
    - 42:14 - Update appsettings.Development.json
    - 44:07 - Create HostConfig static Class
    - 46:00 - Update Program Class - Read in Config
    - 49:55 - Load Certificate into Kestrel
    - 55:13 - Listen on Specific IP Address
    FINAL THOUGHTS & ACKNOWLEDGEMENTS
    - 57:57 - Wrap Up
    - 58:39 - Credits

ความคิดเห็น • 96

  • @binarythistle
    @binarythistle  4 ปีที่แล้ว +14

    ⏲️ *Jump-to Time Codes!* ⏲️
    ----------------------------------------------
    *INTRODUCTION*
    - 2:21 Course Overview
    - 5:46 Demo
    - 6:27 Tooling
    *HTTPS OVERVIEW
    *
    - 6:49 What is HTTPS, SSL & TLS?
    - 7:46 Certificate & Authorities Overview
    - 9:44 What does a certificate contain?
    - 10:30 Public & Private Key Overview
    - 11:48 HTTPS How it Works (Interaction Diagram)
    *LOCALHOST SET UP
    *
    - 14:37 Scaffold Up our API
    - 19:25 Generating a Local Dev Certificate
    - 22:37 The need for a custom domain
    *CUSTOM DOMAIN PART 1
    *
    - 23:56 Update HOSTS File
    - 27:02 Host name resolution order
    - 28:15 Create our Self-Signed Certificate
    - 35:00 Import Certificate into Trusted Root
    *CUSTOM DOMAIN PART 2
    *
    - 36:58 - User Secrets Overview
    - 38:30 - Configure User Secrets
    - 42:14 - Update appsettings.Development.json
    - 44:07 - Create HostConfig static Class
    - 46:00 - Update Program Class - Read in Config
    - 49:55 - Load Certificate into Kestrel
    - 55:13 - Listen on Specific IP Address
    *FINAL THOUGHTS & ACKNOWLEDGEMENTS
    *
    - 57:57 - Wrap Up
    - 58:39 - Credits

  • @adamq272
    @adamq272 ปีที่แล้ว +6

    You are the only one who explain all the details clearly, I appreciate that. Thanks a lot.

  • @antonyrichard369
    @antonyrichard369 2 ปีที่แล้ว +12

    Amazing video. Unbelievable such a kind effort to help others also to learn what you learned. Your sequence of teaching is so good. Thank you very much for this video

  • @insanekelso
    @insanekelso 4 ปีที่แล้ว +2

    Greetings from the Scottish Borders. Why has it taken so long for TH-cam algo to suggest your videos to my feed?? These are without doubt the best tutorials on TH-cam and I watched loads. Love the way you don’t copy/paste code or waffle while typing. Keep them coming

    • @binarythistle
      @binarythistle  4 ปีที่แล้ว

      Hi Ian, thanks mate - I wish I had more control over the TH-cam algorithm! Glad you've found the channel though and are enjoying the content. Cheers, Les

  • @janivimal
    @janivimal 6 หลายเดือนก่อน

    Fantastic session with lots of learning , at the same time very interesting to watch. Thank you for putting so much effort in creating and sharing this with developer community. I would love to see more videos taking step further to see how can we deploy this into cloud , ex running as a container. Thanks again !!

  • @TheDemoded
    @TheDemoded 4 ปีที่แล้ว +5

    There is a Auto completion in Powershell. If you start typing "convertto-s" and press TAB you'll get "ConvertTo-SecureString".
    It works with parameters and directories\files as well.

    • @binarythistle
      @binarythistle  4 ปีที่แล้ว +4

      Hi Andy - where were you a few days ago! You'd have saved me a bit of typing! Great tip & thanks!
      Les

  • @RobertCoulston_au
    @RobertCoulston_au 4 ปีที่แล้ว

    Brilliant - now I understand certificates with some degree of confidence

  • @christopherdunderdale7238
    @christopherdunderdale7238 2 ปีที่แล้ว

    Suddenly getting the urge for a dram while listening to you Les 😅 Great content thank you!

  • @jakubmichalenko7990
    @jakubmichalenko7990 3 ปีที่แล้ว

    Thank you very much, I am just finishing my first production Api and I have been stuck on this for past 2 days :DD

  • @petrkassadinovich2705
    @petrkassadinovich2705 3 ปีที่แล้ว +1

    Thanks for tutorial!
    Btw, you can read configuration file just from .ConfigureKestrel( ), so you don't need to use custom class HostConfig for passing values.
    .ConfigureWebHostDefaults(webBuilder =>
    {
    webBuilder.ConfigureKestrel((context, kestrel) =>
    {
    var file = context.Configuration["CertificateFileLocation"];
    var password = context.Configuration["CertPassword"];
    });
    })

  • @frankoppermann1877
    @frankoppermann1877 24 วันที่ผ่านมา

    Very nice explained. Great job.

  • @manishrao18
    @manishrao18 3 ปีที่แล้ว +1

    Just in case, for intellisense use Windows Powershell ISE and use TAB key for auto-complete

  • @user-lb9kz6fv5n
    @user-lb9kz6fv5n ปีที่แล้ว

    Amazing video. I hope u make another tutorial video for docker

  • @msharief6273
    @msharief6273 3 ปีที่แล้ว

    Thank you! It was treat to watch this video! Loved it ! Enjoyed it !

  • @anasameen6391
    @anasameen6391 4 ปีที่แล้ว +1

    finally it's nice to see you again 🎉🎉

  • @ardonbailey2654
    @ardonbailey2654 3 ปีที่แล้ว

    Thank you for making this. Super helpful. I always appreciate all your videos.

  • @everyonesview
    @everyonesview 4 ปีที่แล้ว +1

    I have enjoyed this one than any other, Les! Many thanks ❤

    • @binarythistle
      @binarythistle  4 ปีที่แล้ว

      Awesome! Wasn't sure about this topic to be honest, it's a little outside of what I usually do, but thought people might find it useful! Glad you enjoyed it!

  • @ricardopfeuti9831
    @ricardopfeuti9831 3 ปีที่แล้ว

    Hi Les. I would like to thank you so much for providing this tutorial. It helped me a lot.

  • @rsodeyi
    @rsodeyi 3 ปีที่แล้ว

    Thank you so much for this. Even the parts you said you wouldn't go deep into were plenty. I was able to secure my local dns and understand better how the whole thing hangs together.
    My issue is that I am working with Nativescript and just for added measure, SignalR as well.
    I've been struggling with trying to get an Android Emulator to communicate with my server while it ignores my hosts file and has it's own version of all my DNSs ...good times.
    I don't see it on your channels as yet but I'm really really hoping it's an area you are planning to explore.
    However, getting this ssl part has really helped to get to the next step of Jumanji Infinity

  • @vladeb1104
    @vladeb1104 3 ปีที่แล้ว

    Best wishes from Scotland (Balloch).

  • @buddyrowe7460
    @buddyrowe7460 4 ปีที่แล้ว

    Hey Les, very well done! Thank you. I've been scouring the Internet trying to find how to use my TLS cert in Kestrel.

  • @rogerfernandes7269
    @rogerfernandes7269 3 ปีที่แล้ว

    You're amazing sir, getting to learn loads of useful stuff from you. Thank you. Keep up the good work.

  • @parsalotfy
    @parsalotfy 3 ปีที่แล้ว

    your tutorials are great man , great, thank you a million

  • @ankushmadankar1756
    @ankushmadankar1756 ปีที่แล้ว

    Very nice video! Saved my day.. Just a question will this work with CA signed certificate on production?

  • @carlitobrigante293
    @carlitobrigante293 3 ปีที่แล้ว

    8:36... "hopefully" we trust ourselves. very deep..

  • @marlonchosky
    @marlonchosky ปีที่แล้ว

    Thanks so much dude! You're video is helping me a lot.
    Question, if I don't want to create a domain name but only use the ip address of my machine, will I only need to generate the certificate but using the ip address instead of the domain name?

  • @shaktisingh-lu3dm
    @shaktisingh-lu3dm ปีที่แล้ว

    Thanks a lot for such great help :)

  • @saurabhchauhan232
    @saurabhchauhan232 4 ปีที่แล้ว

    Thank you very much for this video sir,I really enjoy watching video on this channel.God bless you.

    • @saurabhchauhan232
      @saurabhchauhan232 4 ปีที่แล้ว

      can you make video on real world problem and solution with design patterns

    • @binarythistle
      @binarythistle  4 ปีที่แล้ว

      You are most welcome Saurabh!

  • @Adronius
    @Adronius 2 ปีที่แล้ว

    Would be great to see that updated for .NET 6

  • @arun3836
    @arun3836 4 ปีที่แล้ว +1

    Hi Les , Great video . I really enjoyed it.

    • @binarythistle
      @binarythistle  4 ปีที่แล้ว

      Glad you enjoyed it Arun, Cheers, Les

  • @mister_stadler
    @mister_stadler ปีที่แล้ว

    Fantastic! Thanks a lot!

  • @MarcioAntonioSlivak
    @MarcioAntonioSlivak 4 ปีที่แล้ว

    Thank you very much, you saved my weekend.

  • @KritX01
    @KritX01 4 ปีที่แล้ว +1

    Hey Les, thanks for the amazing content that you put out! It really helps us! I would like to ask you if you could do a video on microservices and microservices internal communication. How would one do it and if can we use kubernetes to scale the microservices. Thanks!

    • @binarythistle
      @binarythistle  4 ปีที่แล้ว +1

      HI there, next videos I'm doing will beL API Gateway, Service Mesh and Asynchronous messaging, all of which really talk about Microservices!

    • @KritX01
      @KritX01 4 ปีที่แล้ว

      @@binarythistle oh yes please thank you! :D

  • @2005bgva
    @2005bgva 3 ปีที่แล้ว

    Fantastic video, thanks a lot. One question, are you going to do a video for a production enviroment?

  • @ayxanalifov2791
    @ayxanalifov2791 4 ปีที่แล้ว

    Thanks so much... Very high quality content !!!

  • @lifeisgameplayit
    @lifeisgameplayit ปีที่แล้ว

    I like your content , thanks m8 !

  • @motomiprysork4923
    @motomiprysork4923 3 ปีที่แล้ว +1

    Thank you for another great video! I followed along with my API and works great within my dev machine. One question though in my dev environment, I need to call this API from another dev machine (2nd machine) in the same network. I'm trying to reach the API using IP address since I don't have the host file set up on the 2nd machine. I'm getting certificate issue. These 2 machines can ping each other.

  • @stampgermany
    @stampgermany 2 ปีที่แล้ว

    You've helped a lot!
    Thanks!

  • @glennsingh354
    @glennsingh354 2 ปีที่แล้ว

    Thanks a lot for this wonderful content.

  • @shahid13384
    @shahid13384 3 ปีที่แล้ว

    Thank you for great explanation

  • @patrickcandlin7420
    @patrickcandlin7420 3 หลายเดือนก่อน

    ❤ PowerShell here

  • @maxbitran
    @maxbitran 3 ปีที่แล้ว

    Thanks man! Really helpful.

  • @luizacacio2012
    @luizacacio2012 2 ปีที่แล้ว

    Jackson, do you have any videos showing api with digital authentication? I need to prepare my api to receive notification from a webhook, which uses mtls for communication.

  • @AGMXZ1
    @AGMXZ1 4 ปีที่แล้ว

    Thanks Les. I'm struggling with getting my react app and jquery to talk to my local webapi so I'm hoping this does the trick.

    • @AGMXZ1
      @AGMXZ1 4 ปีที่แล้ว

      Still failing for me. I'm trying this on my corporate desktop computer. When I run the GET against the weatherforecast from Postman with HTTPS verification enabled it also fails. When I disable verification I get data back, even using the DNS name which is cool, but the SSL verification fails. When I look at the warning in the Postman console I get:
      Warning: Unable to verify the first certificate
      When I look further down in the warning in the TLS section I see something perhaps more specific.
      authorizationError: "UNABLE_TO_VERIFY_LEAF_SIGNATURE"

  • @Teutathis
    @Teutathis 4 ปีที่แล้ว

    DHCP is Dynamic Host _Configuration_ Protocol. Great video though

  • @LakhanSINGH-rk9et
    @LakhanSINGH-rk9et 4 ปีที่แล้ว

    Hi Les , This was a great video . Totally loved it
    Would you be making video on EshopOnContainers microservices ?

    • @binarythistle
      @binarythistle  4 ปีที่แล้ว

      Hi Lakhan, yes I'm working on something at the moment, I've taken EshopOnContiners and am re-working it slightly to make it easier to teach with. Hopefully not too long before I complete it.

    • @LakhanSINGH-rk9et
      @LakhanSINGH-rk9et 4 ปีที่แล้ว

      @@binarythistle Thanks Les , Waiting for that video to come out. Would be supporting that video on patreon

  • @diegobaroffio4462
    @diegobaroffio4462 3 ปีที่แล้ว

    Hi Les, Thank you for your very well structured video, it's great.
    One question: Any reason why not reading the certificate from the Certificate Store instead of reading from file?
    This way you don't have even to worry with passwords.
    Regards.

  • @jasonbartlett1357
    @jasonbartlett1357 ปีที่แล้ว

    Great tutorial. I'm doing this in .NET 6 and using minimal api approach. I have a question about using options.ListenAnyIP vs. the Dns host approach: If use ListenAnyIP, when I run the app, it opens to the url I have in the config, (and the url matches the cert url), But, if I use the resolved DNS ip, when I run the app, it doesn't open the url, and if I go to the url, it can't validate the certificates. So what options can I use to have it go to the url, rather than try to use the ip address?

  • @gajarubanjeyakumar7226
    @gajarubanjeyakumar7226 2 ปีที่แล้ว

    Thankyou!

  • @aikidoshi007
    @aikidoshi007 4 ปีที่แล้ว +3

    Hi Les, nice video, this has always been a mystery to me. One issue I have noticed is that although Edge works as shown, Chrome still says the certificate is Invalid. Not sure why, any ideas? It does come good after setting up the certificate etc.
    Bad luck about Melbourne being back in lockdown, I'm in Forest Hill and was excited about starting to get out again :-(

    • @binarythistle
      @binarythistle  4 ปีที่แล้ว +3

      Hi Steve. This drove me crazy for a bit until I restarted the browser! I should have mentioned that in the video. Drop us a line if that doesn't resolve it - seems to be working in Chrome for me, (after the restart). Another thing I should have mentioned is that Firefox uses its own cert store so uses will need to import the cert following these instructions: knowledge.digicert.com/solution/SO5437
      Yeah lock-down again is a pain, but I guess it's for the greater good! Hopefully the numbers start to drop. Thanks for feeding back, and stay safe, Les

    • @radeksendecki9922
      @radeksendecki9922 3 ปีที่แล้ว

      I had the same issue. Thanks for Your question and aswer :)

  • @paulsanchez5030
    @paulsanchez5030 ปีที่แล้ว +1

    Did you find a good Open SSL article?

  • @vpep5439
    @vpep5439 4 ปีที่แล้ว

    Thank you very much for sharing videos

  • @joseperezbalan7788
    @joseperezbalan7788 ปีที่แล้ว

    could you make a video for certs in ubuntu or linux base os ?, i have spend three days and still have not got it to work.. dev certs for linux is a pain in the ass .

  • @crazyhiker379
    @crazyhiker379 4 ปีที่แล้ว

    Thanks boss for your contents.

  • @EminoMeneko
    @EminoMeneko ปีที่แล้ว

    On my work machine it... works.
    On Linux too.
    On my personal machine it... gets personal and throws 'System.Security.Cryptography.CryptographicException' occurred in System.Security.Cryptography.dll: 'Access denied.'
    Any idea what makes it break ?

  • @anbupa
    @anbupa ปีที่แล้ว

    Hola desde chile.. Si no quisiera levantarlo con Kestrel sino por iis express como sería?

  • @CarlosAndres-lv1zq
    @CarlosAndres-lv1zq 3 ปีที่แล้ว

    Thank you so much

  • @darshanyadav4784
    @darshanyadav4784 2 ปีที่แล้ว

    Hello, I've a doubt. How do change the url length in kestrel so that I can pass strings of larger length?

  • @petargavrilov976
    @petargavrilov976 2 ปีที่แล้ว

    Hi Les. I wonder why don't we remove the http entry from application url and just use https only ?

  • @aliascross
    @aliascross 3 ปีที่แล้ว

    Thanks, It's works well with Edge browser, but in my case, it does not work with Firefox or Safari (which ask to add an exception).
    Custom Certificate is it the good way to use API https connection a LAN Production project ?

  • @nick11927
    @nick11927 4 ปีที่แล้ว

    Thank you!

  • @mateuszkaleta1495
    @mateuszkaleta1495 2 ปีที่แล้ว

    is this a big difference when we configure our SSL only in application code / or only in server configuration?

  • @alxizr
    @alxizr 3 ปีที่แล้ว

    @Les Jackson
    #Les Jackson
    Hi, I was wondering if there is a way to utilize Typescript with dotnet core 3.1 and web api? I would really love to see the use of Typescript in the backend on dotnet core.

  • @kalpeshblue2
    @kalpeshblue2 4 ปีที่แล้ว +1

    Super Like

  • @DanielFantaneanu
    @DanielFantaneanu 3 ปีที่แล้ว

    nice

  • @nathanwaterman4380
    @nathanwaterman4380 3 ปีที่แล้ว

    `dotnet dev-certs https --trust` doesn't work for me. It creates the certificate but doesn't Trust it. It only appears under Personal Certificates :/

    • @nathanwaterman4380
      @nathanwaterman4380 3 ปีที่แล้ว

      Brilliant! As part of following this tutorial I discovered that my anti-virus, WebRoot, was blocking the creation of trusted certificates. It was also stopping me from the updating the host file.

  • @bblair2010
    @bblair2010 3 ปีที่แล้ว

    Hey Les, I would I get this to work when deployed in Azure?

  • @khaledslaimia3135
    @khaledslaimia3135 3 ปีที่แล้ว

    what i fin dissapointing is a channel like that where we find a real treasure have little subscribers meanwhile gaming channels have millions.

  • @3AgL3DeeJay
    @3AgL3DeeJay 3 ปีที่แล้ว

    PLEASE HELP MEE!!!
    Amazing video but if I add that "var host = Dns.GetHostEntry("");" line in program.cs my code jumps to that line instead of entering into ".ConfigureServices((context, services) =>"... any idea why??? I'm trying to get the string with the domain from config so I'm using it like this: prnt.sc/vwnlaq
    thanks!

    • @3AgL3DeeJay
      @3AgL3DeeJay 3 ปีที่แล้ว

      Solved it! Now I get a "The requested address is not valid in its context" error....

    • @3AgL3DeeJay
      @3AgL3DeeJay 3 ปีที่แล้ว

      Nevermind, I solved it! :D I was using the domain IP in the localhost. Thanks for the video man!

  • @geojaya
    @geojaya 3 ปีที่แล้ว

    Any one knows how to CA Signed Certificate to a custom domain using Kestrel

  • @zenobiusztasak8604
    @zenobiusztasak8604 3 ปีที่แล้ว

    Does it work on .net 5 ? I get an error NET::ERR_CERT_COMMON_NAME_INVALID