C#C
C#4y 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

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)

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)
Was this page helpful?