Решение проблемы невалидного tls-сертификата
This commit is contained in:
@@ -10,7 +10,7 @@ class RemoteStorage {
|
|||||||
|
|
||||||
this.accessToken = this.config.accessToken;
|
this.accessToken = this.config.accessToken;
|
||||||
|
|
||||||
this.wsc = new WebSocketConnection(config.url);
|
this.wsc = new WebSocketConnection(config.url, 10, 30, {rejectUnauthorized: false});
|
||||||
}
|
}
|
||||||
|
|
||||||
async wsRequest(query) {
|
async wsRequest(query) {
|
||||||
|
|||||||
@@ -8,10 +8,13 @@ const cleanPeriod = 5*1000;//5 секунд
|
|||||||
|
|
||||||
class WebSocketConnection {
|
class WebSocketConnection {
|
||||||
//messageLifeTime в секундах (проверка каждый cleanPeriod интервал)
|
//messageLifeTime в секундах (проверка каждый cleanPeriod интервал)
|
||||||
constructor(url, openTimeoutSecs = 10, messageLifeTimeSecs = 30) {
|
constructor(url, openTimeoutSecs = 10, messageLifeTimeSecs = 30, webSocketOptions = {}) {
|
||||||
this.WebSocket = (isBrowser ? WebSocket : require('ws'));
|
this.WebSocket = (isBrowser ? WebSocket : require('ws'));
|
||||||
this.url = url;
|
this.url = url;
|
||||||
|
this.webSocketOptions = webSocketOptions;
|
||||||
|
|
||||||
this.ws = null;
|
this.ws = null;
|
||||||
|
|
||||||
this.listeners = [];
|
this.listeners = [];
|
||||||
this.messageQueue = [];
|
this.messageQueue = [];
|
||||||
this.messageLifeTime = messageLifeTimeSecs*1000;
|
this.messageLifeTime = messageLifeTimeSecs*1000;
|
||||||
@@ -89,9 +92,9 @@ class WebSocketConnection {
|
|||||||
if (isBrowser) {
|
if (isBrowser) {
|
||||||
const protocol = (window.location.protocol == 'https:' ? 'wss:' : 'ws:');
|
const protocol = (window.location.protocol == 'https:' ? 'wss:' : 'ws:');
|
||||||
const url = this.url || `${protocol}//${window.location.host}/ws`;
|
const url = this.url || `${protocol}//${window.location.host}/ws`;
|
||||||
this.ws = new this.WebSocket(url);
|
this.ws = new this.WebSocket(url, this.webSocketOptions);
|
||||||
} else {
|
} else {
|
||||||
this.ws = new this.WebSocket(this.url);
|
this.ws = new this.WebSocket(this.url, this.webSocketOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
const onopen = () => {
|
const onopen = () => {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
require('tls').DEFAULT_MIN_VERSION = 'TLSv1';
|
require('tls').DEFAULT_MIN_VERSION = 'TLSv1';
|
||||||
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
|
|
||||||
|
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const argv = require('minimist')(process.argv.slice(2));
|
const argv = require('minimist')(process.argv.slice(2));
|
||||||
|
|||||||
Reference in New Issue
Block a user