如何让枪接受自签名证书?

时间:2017-10-24 15:11:46

标签: javascript gun

枪0.8.8,Node.js-to-Node.js,Node.js-to-browser

我在浏览器控制台中看到以下错误:

null

Node.js端没有消息。

我服务器的Sorce代码:

VM103:161 WebSocket connection to 'wss://127.0.0.1:8080/gun' failed: Error in connection establishment: net::ERR_INSECURE_RESPONSE
VM103:161 WebSocket connection to 'wss://10.42.0.56:8080/gun' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

1 个答案:

答案 0 :(得分:1)

为了使gun能够使用自签名证书,您需要做两件事:

  1. 午餐浏览器忽略证书错误。例如,Chrome

    google-chrome --ignore-certificate-errors

  2. 在Node.js代码中添加以下进程选项

    process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';

    或添加环境变量

    export NODE_TLS_REJECT_UNAUTHORIZED=0