您如何重新创建 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:
您的连接不是私密的"
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 serve --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屋!