node.js - npm CA 证书的位置

标签 node.js ssl npm

我们有一个公司授权的 SSL MITM,我正试图让 npm 很好地使用它。没有配置,npm install 产生

$ npm install --verbose
...
npm verb request uri https://registry.npmjs.org/request
npm verb request no auth needed
npm info attempt registry request try #1 at 12:21:46
npm verb etag "BHYPP2OQ6VBKY2B3TPXTCBVRQ"
npm http request GET https://registry.npmjs.org/request
npm info retry will retry, error on last attempt: Error: SELF_SIGNED_CERT_IN_CHAIN
npm info retry will retry, error on last attempt: Error: SELF_SIGNED_CERT_IN_CHAIN
npm info retry will retry, error on last attempt: Error: SELF_SIGNED_CERT_IN_CHAIN
...

当我把我们的 custom SSL pem in ~/.npmrc

ca="-----BEGIN CERTIFICATE-----\n..."

我得到以下信息

$ npm install --verbose
...
npm http request GET https://registry.npmjs.org/time-grunt
npm verb request uri https://registry.npmjs.org/request
npm verb request no auth needed
npm info attempt registry request try #1 at 12:27:17
npm verb etag "BHYPP2OQ6VBKY2B3TPXTCBVRQ"
npm http request GET https://registry.npmjs.org/request
npm info retry will retry, error on last attempt: Error: Hostname/IP doesn't match certificate's altnames
npm info retry will retry, error on last attempt: Error: Hostname/IP doesn't match certificate's altnames
...

如果我理解正确的话,npm 将那个 SSL 证书用作唯一的根 CA,这就是为什么它不起作用的原因。没有用 ca[]="-----BEGIN CERTIFICATE-----\n..." 行来膨胀 ~/.npmrc CA,是否有单个 certs.pem 文件我可以将我们的内部 pem 附加到?

我正在寻找类似于我让自制软件安装的应用程序正常工作的方式

cat internal-cert.pem >> /usr/local/etc/openssl/cert.pem

我希望 npm/node 也有类似的东西。

最佳答案

尝试设置 strict-ssl 标志。我以前有过类似的问题。

npm 配置设置 strict-ssl false

我实际上从我的 ~/.npmrc 中取出了证书,但不确定你是否将它留在里面是否会影响任何东西。

关于node.js - npm CA 证书的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29104723/

相关文章:

npm - 为什么 `npm install` 使用收缩包装的 'resolved' 属性

node.js - 从 shell 运行 'npm install' 也会运行 'prepublish' 脚本

javascript - 如何检查一个对象是否是跨 V8 上下文的正则表达式?

node.js - Jade 和 NodeJs,有什么好的教程吗?

php - 在 HTTP WordPress 站点中加载外部 HTTPS 脚本

performance - Haproxy SNI 与 HTTP 主机 ACL 检查性能

npm - docpad run 不断询问服务条款

javascript - 使用 Jasmine 或任何其他替代方案在 Node 上运行测试 .mjs/ESM

javascript - 我是否正确使用了 Promise?

ssl - HTTPS URL 重定向不适用于 HaProxy