node.js - npm 信任自签名证书

标签 node.js git ssl npm ssl-certificate

我在个人服务器上有一个 git 存储库,它使用自签名证书。

我想做的是将此 CA 添加到 npm 的受信任的 CA,以便像这样从 repo 安装软件包:

npm install git+https://domain.tld/repo.git

以下命令允许我信任我的服务器,但在那之后,我的本地 npm 不再信任 npm.org 存储库。

npm config set cafile=/usr/local/share/ca-certificates/domain.tld/ca.crt
npm config set ca="content-of-my-cert"

注意:它与 git+ssh:// 配合使用效果很好,但由于其他人会使用此包,我不想添加新的受信任的 ssh key 每次有新的消费者...

最佳答案

您对 cafile 和 ca 的设置正在清除默认的受信任 CA 证书。您可以使用 ca[] 数组信任多个 CA 证书,如下所示:

npm config set ca[]="content_of_your_CA_cert"
npm config set ca[]="content_of_the_npm_root_cert"
npm config set ca[]="content_of_the_npm_intermediate_cert"

附言- npm.org 是全国田园音乐家协会。如果您指的是 npmjs.com,则该证书当前由 DigiCert 使用 this intermediate cert 签名和 this root cert .

关于node.js - npm 信任自签名证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33936801/

相关文章:

javascript - N 可以表示为 js 中 K 因子乘积的多种方式

git - git commit -S 和 -s 有什么区别?

GitHub pull 请求 : How to merge and fast-forward to avoid "recent changes" and diff notifications

python - 在带有 Google Cloud 服务的 Python 中使用多处理时出现 SSL 错误

node.js - 在 NodeJS 中检索 POST 请求的 JSON 响应

node.js - 用于 e2e 前端测试的暂存后端

node.js - 如何在 NestjS 中使用可选的 url 参数

git - 在 Cygwin 中无法看到 git 颜色

c# - 关于使用自签名证书在 IIS 7.0 上启用 SSL 的问题

java - 通过 Websphere over SSL 连接到 Oracle 的 RSA premaster secret 错误