Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you recreate the automatically generated self-signed cert that the Angular CLI creates?

I've been running ng serve --ssl on my current project for some time with no issue. The first time I ran it, angular automatically created a self-signed cert. My browser rejected it which is expected, so I exported it and imported it into my local trusted root certificates and turned on the Chrome flag chrome://flags/#allow-insecure-localhost to allow me to use untrusted certs from localhost. So all was well for a while.

Today I'm running ng serve --ssl and I'm getting the following error:

"Your connection is not private"

"NET::ERR_CERT_DATE_INVALID"

After inspecting the cert, sure enough, the cert has expired.

How do I get ng serve --ssl to create a new cert and stop using the old expired one? I've already tried deleting the old expired one in my local cert management console but the same old expired cert is re-used whenever I run ng serve --ssl

like image 650
Post Impatica Avatar asked Dec 23 '22 16:12

Post Impatica


1 Answers

Apparently the Angular CLI only creates a 1 month certificate when it autogenerates a cert. I downloaded and used Micrsoft's SysInternals ProcessMonitor to find the fix.

  1. Stop ng serve --ssl if it's still running
  2. Delete node_modules\webpack-dev-server\ssl\server.pem
  3. Restart ng serve --ssl and you should have a new 30 day cert.
like image 58
Post Impatica Avatar answered Dec 28 '22 10:12

Post Impatica