matmanjs / matman

Web 端对端测试(E2E,End-to-End Testing)解决方案
https://matmanjs.github.io/matman
MIT License
46 stars 10 forks source link

在某些情况下https请求没法走代理的问题 #159

Closed helinjiang closed 4 years ago

helinjiang commented 4 years ago

当我们设置了 proxyServer 走代理时,发现某些情况下 https 根本不会走到代理中,但是 http 是可以的。

如果用 curl 来验证,可以看到类似下面的错误

curl: (60) Peer's Certificate issuer is not recognized.
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.
helinjiang commented 4 years ago

解决方案:https://www.npmjs.com/package/nightmare#switches , 需要设置ignore-certificate-errors

const nightmare = Nightmare({
  switches: {
    'proxy-server': '1.2.3.4:5678',
    'ignore-certificate-errors': true
  }
})
helinjiang commented 4 years ago

已在 v4.0.14 版本解决