© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
1 reply
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
mywebsite.com
. I'm trying to redirect
api.mywebsite.com
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
mywebsite.com
or
api.mywebsite.com
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)
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ ASP.NET to .net Core
C#CC# / help
3y ago
asp.net ssl certificate?
C#CC# / help
3y ago
ASP.NET CORE MVC VS ASP.NET CORE WEB API
C#CC# / help
17mo ago