Add generated Angular cert to Trusted Root store

Filed under: angular, .net

When creating a standalone Angular app in Visual Studio, a cert will be automatically created. This can be seen in the console window created by ng serve like the following:

ng serve --ssl -ssl-cert %APPDATA%\https\%npm_package_name%.pem --ssl-key %APPDATA%\ASP.NET\https\%npm_package_name%.key

However, when you go to the browser, there will be an error for the certificate even though it is not expired.

This is because you need to add localhost to your Trusted Root Certificate Store in Windows.

To do this, run the following command from an elevated command prompt where <username> is your Windows account name and <ProjectName> is the name of your project:

certutil -addstore -f "Root" C:\Users\<username>\AppData\Roaming\ASP.NET\https\<ProjectName>.pem

Now, the next time you run the application, your certification will be valid.

Sources

Importing .PEM certificates on Windows 7 on the command line

© 2022 JASON RAE