【问题标题】:npm trust self-signed certificatenpm 信任自签名证书
【发布时间】:2015-12-04 13:23:38
【问题描述】:

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

我想做的是将此 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"

NB:它适用于git+ssh://,但由于其他人会使用此包,我不想每次有新消费者时都添加新的受信任的 ssh 密钥...

【问题讨论】:

    标签: node.js git ssl npm ssl-certificate


    【解决方案1】:

    您对 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 certthis root cert 签名。

    【讨论】:

    • 感谢您的回答。是的,我的意思是 npmjs.com,我不认为全国田园音乐家协会在 node 的生态系统中非常活跃......
    猜你喜欢
    • 2018-03-10
    • 2016-11-29
    • 2019-09-03
    • 1970-01-01
    • 2018-03-20
    • 1970-01-01
    • 1970-01-01
    • 2021-04-07
    • 1970-01-01
    相关资源
    最近更新 更多