我在个人服务器上有一个 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/