Step 6/17 : RUN bower install --allow-root ---> Running in 20f9229dcd1e bower angular-touch#~1.5.0 CERT_HAS_EXPIRED Request to https://registry.bower.io/packages/angular-touch failed: certificate has expired
这个镜像的构建大约持续了两年时间,突然间就不再合作了。我该如何刷新缺失的证书呢?
"strict-ssl": false,
"https-proxy": "",
这是一种解决方法,但这是不好的做法。然而,使用过时的插件和bower也是不好的做法。
你们可能都在使用“非常老”的构建堆栈,基于旧版Node Docker镜像,并使用旧版的Debian发行版作为其基本镜像(即node:6
=> Debian Stretch)。
看起来,registry.bower.io的letsencrypt证书已于2023年4月24日更新,此后使用了更现代的中间证书。这在原始的基于旧版Debian发行版的Node镜像上是不可用/未知的。
当然,现在正是升级您的构建堆栈的时候了,但在此期间,您可以使用以下解决方法。
将以下内容添加到Dockerfile中,在执行bower install
之前进行解决:
node:6
/ Debian Strech# manually remove expired letsencrypt X3 certificate and install the new ISRG X1 root CA
RUN mkdir -p /usr/share/ca-certificates/letsencrypt/ \
&& cd /usr/share/ca-certificates/letsencrypt/ \
&& curl -kLO https://letsencrypt.org/certs/isrgrootx1.pem \
&& perl -i.bak -pe 's/^(mozilla\/DST_Root_CA_X3.crt)/!$1/g' /etc/ca-certificates.conf \
&& update-ca-certificates
然后使用此标志告诉Bower使用系统范围的CA系统:
RUN NODE_OPTIONS=--use-openssl-ca bower install ...
node:4
/ Debian Jessie无法让这个古老的 npm 使用 openssl-ca,因此在这种情况下禁用 SSL 检查:
RUN <<EOR
cat <<EOF > .bowerrc
{
"registry": "https://registry.bower.io",
"strict-ssl": false,
"https-proxy": ""
}
EOF
EOR
RUN cd /
运行无效。https://dev59.com/WlMH5IYBdhLWcg3wpgtd更正确的步骤:RUN mkdir -p /usr/share/ca-certificates/letsencrypt/
WORKDIR /usr/share/ca-certificates/letsencrypt
RUN curl -kLO https://letsencrypt.org/certs/isrgrootx1.pem \ && perl -i.bak -pe 's/^(mozilla\/DST_Root_CA_X3.crt)/!$1/g' /etc/ca-certificates.conf \ && update-ca-certificates
- Andrey FedosenkoRUN cd /
。 - Ernesto Baschny在 .bowerrc
中指向新的注册表
答案见此处
{
"directory": "bower_components",
"registry": "https://bower.herokuapp.com"
}
"dependencies": {
"bootstrap-sass": "3.2.0",
"jquery": "2.2.0",
...
}
然后将其更改为:
"dependencies": {
"bootstrap-sass": "https://github.com/twbs/bootstrap-sass.git#3.2.0",
"jquery": "https://github.com/jquery/jquery.git#2.2.0",
...
}
bower install
仍适用于更新版本的node。
从我所注意到的来看,证书已经停止适用于6、7和8版本。
解决方法是:只在更新的node(例如12)上执行bower install
命令,而其余构建项目的命令则在我需要的版本上执行。
这在我们的项目中起作用了。
将Node版本从8升级到18对我解决了这个错误。
不确定是否正确,但以下步骤对我们有效:
1 - 删除旧证书:
sed -i 's/mozilla\/DST_Root_CA_X3.crt/!mozilla\/DST_Root_CA_X3.crt/g' /etc/ca-certificates.conf
2 - 更新证书:
update-ca-certificates
3 - 暂时禁用SSL:在.bowerrc文件中添加"strict-ssl": false
。
4 - 在您的步骤中,在bower install
命令之前添加bower cache-clean
。
5 - 在bower install
命令中包含标志--use-openssl-ca
。
6 - 运行您的构建,这次应该可以工作了。
7 - 返回并启用SSL:从.bowerrc文件中删除"strict-ssl": false
。
8 - 下一次构建应该可以使用SSL而不会出现证书问题。