C
C#•3y ago
Stay

[ASP.NET Core] Apply a selfsigned certificate to asp.net core?

So i don't know exactly what i'm doing, but i'm trying to do the following: Let's say that i have the following domain purchased: mywebsite.com. I'm trying to redirect api.mywebsite.com to localhost by adding in the hosts file
api.mywebsite.com 127.0.0.1
api.mywebsite.com 127.0.0.1
As expected this does not play nice with browsers or other programs, because the certificate provided by ASP.NET Core has nothing to do with mywebsite.com or api.mywebsite.com. I tried creating a self signed certificate like this in Powershell
New-SelfSignedCertificate -DnsName "api.mywebsite.com" -CertStoreLocation cert:\LocalMachine\My -FriendlyName "Dev cert for api.mywebsite.com" -NotAfter (Get-Date).AddYears(15)
New-SelfSignedCertificate -DnsName "api.mywebsite.com" -CertStoreLocation cert:\LocalMachine\My -FriendlyName "Dev cert for api.mywebsite.com" -NotAfter (Get-Date).AddYears(15)
But i don't know how to use that in ASP.NET Core (if that's even what i have to do to make this work) So is this possible or using a domain like that in localhost is completly impossible (without warnings atleast)
1 Reply
x0rld 👻 🎃
https://learn.microsoft.com/en-us/dotnet/core/additional-tools/self-signed-certificates-guide i think you can follow this they explain how to do with powershell ignore the docker if you don't use it
Generate Self-Signed Certificates Overview - .NET
An overview of the Microsoft dotnet dev-certs tool that adds functionality for .NET Core and ASP.NET Core projects, and other options for using self-signed certificates.
Want results from more Discord servers?
Add your server