如何从电子应用程序调试“无法验证第一证书”?

时间:2019-08-26 10:53:28

标签: google-chrome ssl electron

我正在尝试通过电子应用程序(渲染过程)连接到wss://mydomain.com/ws,但是:

events.js:177 Uncaught Error: unable to verify the first certificate
    at TLSSocket.onConnectSecure (_tls_wrap.js:1317)
    at TLSSocket.emit (events.js:200)
    at TLSSocket._finishInit (_tls_wrap.js:792)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:606)

我使用的代码适用于普通的Chrome和Firefox浏览器

const WebSocket = require('isomorphic-ws')

const ws = new WebSocket('wss://mydomain.com/',
      [],
      {
        headers: {
          Cookie: cookie.serialize('X-Authorization', bearerToken),
        },
      },
);

我使用了https://www.ssllabs.com/ssltest/analyze.html?d=mydomain.com 检查证书,上面写着:

Protocols
TLS 1.3 No
TLS 1.2 Yes
TLS 1.1 Yes
TLS 1.0 Yes
SSL 3   No
SSL 2   No
For TLS 1.3 tests, we only support RFC 8446.

但是我在电子devtools中看不到请求,所以无法验证tls版本

1 个答案:

答案 0 :(得分:0)

使用https://www.ssllabs.com/ssltest/我发现

Chain issues.........Incomplete

因此,在使用之前,我将其固定在nginx上:

ssl_certificate /www/xx/certs/mydomain_com.crt;
ssl_certificate_key /www/xx/certs/live_server.key;

现在我做了:

cat mydomain-com.crt mydomain-com.ca-bundle > mydomain_com.ca-bundle.crt

并在nginx中进行了更改:

ssl_certificate /www/xx/certs/mydomain_com.ca-bundle.crt;
ssl_certificate_key /www/xx/certs/live_server.key;