NPM安装错误:证书链中的自签名证书

时间:2019-07-23 07:12:15

标签: ssl npm npm-install cypress

在我公司,有一个自动签名的ssl证书。因此,它们是一些无法安装的npm软件包。

我已经在strict-ssl=false.npmrc命令参数中添加了--strict-ssl=false

它适用于某些软件包,但有些似乎不负责此选项。

例如,我尝试安装 Cypress

命令:

npm i cypress --save-dev --strict-ssl=false

错误日志:

> cypress@3.4.0 postinstall /Users/mchoraine/Documents/Workplace/SAMSE/rechercheproduit/rechercheproduit-front/node_modules/cypress
> node index.js --exec install

Installing Cypress (version: 3.4.0)

 ✖  Downloading Cypress    
   → Cypress Version: 3.4.0
    Unzipping Cypress      
    Finishing Installation 
The Cypress App could not be downloaded.

Please check network connectivity and try again:

----------

URL: https://download.cypress.io/desktop/3.4.0?platform=darwin&arch=x64
Error: self signed certificate in certificate chain

----------

Platform: darwin (18.6.0)
Cypress Version: 3.4.0

似乎仅对于带有postinstall的软件包才会出现问题

最聪明的事情是更改SSL证书,但不幸的是,它无法完成。

那么您知道在npm postinstall上绕过证书验证的替代方法吗?

预先感谢您的建议。

2 个答案:

答案 0 :(得分:1)

获取公司证书的副本,然后在运行npm指令之前将NODE_EXTRA_CA_CERTS环境变量设置为指向它:

export NODE_EXTRA_CA_CERTS=path/to/certificate.crt

安装后脚本是一个单独的节点程序,因此npm标志不会对其产生影响。

信用归“ zerdos”负责,他在一个相关的GitHub问题上发布了此解决方案:https://github.com/cypress-io/cypress/issues/1401#issuecomment-393591520

答案 1 :(得分:0)

对我来说,以下解决方案有效。

<块引用>

操作系统 - Windows 10

终端 - git bash

在安装 cypress 之前运行这些命令。

template <typename Child, typename T>
class IClient {
  const std::vector<T>& getID() {
      return asChild()->getID();
  }

  bool isEqual(const std::vector<T>& anotherID) {
      return asChild()->isEqual(anotherID);
  }

  bool operator==(const Child& anotherClient) {
      return asChild()->isEqual(anotherClient);
  }

private:
  Child* asChild() {
      return static_cast<Child*>(this);
  }
  const Child* asChild() const {
      return static_cast<const Child*>(this);
  }

};

class SeviceClient : public IClient<SeviceClient, int8_t> {
  const std::vector<int8_t> ID;

public:
  SeviceClient(const std::vector<int8_t>& ID) : ID(std::move(ID)) {}
  SeviceClient(const std::vector<int8_t>&& ID) : ID(std::move(ID)) {}

  const std::vector<int8_t>& getID() {
      return ID;
  }
  bool isEqual(const std::vector<int8_t>& anotherID) {
      return true;
  }
  bool operator==(const SeviceClient& anotherClient) {
      return true;
  }
};

这些将在您的系统中设置为环境变量以供将来使用。 如果您不需要它们,您可以随时摆脱它们。