如何重新创建Angular CLI创建的自动生成的自签名证书? [英] How do you recreate the automatically generated self-signed cert that the Angular CLI creates?
问题描述
我已经在我当前的项目上运行 ng serve --ssl
一段时间了,没有问题.我第一次运行它时,angular会自动创建一个自签名证书.我的浏览器拒绝了预期的操作,因此我将其导出并将其导入到本地受信任的根证书中,并打开了Chrome标志 chrome://flags/#allow-insecure-localhost
以允许我使用来自本地主机的不受信任的证书.所以一阵子一切都很好.
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.
今天我正在运行 ng serve --ssl
,并且遇到以下错误:
Today I'm running ng serve --ssl
and I'm getting the following error:
您的连接不是私有的"
"Your connection is not private"
" NET :: ERR_CERT_DATE_INVALID"
"NET::ERR_CERT_DATE_INVALID"
检查证书后,请确保证书已过期.
After inspecting the cert, sure enough, the cert has expired.
如何获取 ng serve --ssl
来创建新证书并停止使用过期的旧证书?我已经尝试在本地证书管理控制台中删除旧的过期证书,但是每当我运行 ng serve --ssl
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
推荐答案
显然,Angular CLI在自动生成证书时只会创建一个1个月的证书.我下载并使用了Micrsoft的SysInternals ProcessMonitor来找到修复程序.
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.
- 如果仍在运行,请停止
ng服务--ssl
- 删除
node_modules \ webpack-dev-server \ ssl \ server.pem
- 重新启动
ng serve --ssl
,您应该拥有一个新的30天证书.
- Stop
ng serve --ssl
if it's still running - Delete
node_modules\webpack-dev-server\ssl\server.pem
- Restart
ng serve --ssl
and you should have a new 30 day cert.
这篇关于如何重新创建Angular CLI创建的自动生成的自签名证书?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!