@@ -11,7 +11,6 @@ import { GlobalControllerAborter } from "./GlobalControllerAborter";
11
11
import { DispatchableItem } from './DispatchableItem' ;
12
12
import { HttpsProxyAgent } from 'https-proxy-agent' ;
13
13
import { HttpProxyAgent } from 'http-proxy-agent' ;
14
- import * as syswideCa from "syswide-cas" ;
15
14
import { Utils } from '../../Utils/Utils' ;
16
15
17
16
const MAX_CONCURRENT_REQUEST = 30 ;
@@ -31,6 +30,8 @@ export class Dispatcher extends EventEmitter {
31
30
32
31
private proxyAgent : HttpsProxyAgent | HttpProxyAgent ;
33
32
33
+ private caCert : string ;
34
+
34
35
constructor ( scannerCfg = new ScannerCfg ( ) ) {
35
36
super ( ) ;
36
37
this . scannerCfg = scannerCfg ;
@@ -44,23 +45,19 @@ export class Dispatcher extends EventEmitter {
44
45
45
46
//Loads proxy from SDK config, if not, loads from env variables, if not, leave empty
46
47
this . proxyAgent = null ;
48
+ this . caCert = null ;
49
+
47
50
const proxyAddr = this . scannerCfg . PROXY || process . env . https_proxy || process . env . HTTPS_PROXY || process . env . http_proxy || process . env . HTTP_PROXY || null ;
51
+ const caCertPath = this . scannerCfg . CA_CERT || process . env . NODE_EXTRA_CA_CERTS
52
+
53
+ if ( caCertPath ) Utils . loadCaCertFromFile ( caCertPath ) ;
54
+ else if ( this . scannerCfg . IGNORE_CERT_ERRORS || proxyAddr ) process . env . NODE_TLS_REJECT_UNAUTHORIZED = "0" ;
48
55
49
56
if ( proxyAddr ) {
50
57
if ( this . scannerCfg . API_URL . trim ( ) . startsWith ( 'https' ) ) this . proxyAgent = new HttpsProxyAgent ( proxyAddr ) ;
51
58
else this . proxyAgent = new HttpProxyAgent ( proxyAddr ) ;
52
59
}
53
60
54
- //Loads certs stuff from SDK config
55
- const ca_cert = this . scannerCfg . CA_CERT || process . env . NODE_EXTRA_CA_CERTS
56
- if ( ca_cert ) {
57
- const syswidecas = require ( 'syswide-cas' ) ;
58
- syswideCa . addCAs ( ca_cert )
59
- } else {
60
- if ( this . scannerCfg . IGNORE_CERT_ERRORS || proxyAddr )
61
- process . env . NODE_TLS_REJECT_UNAUTHORIZED = "0" ;
62
- }
63
-
64
61
this . pQueue = new PQueue ( {
65
62
concurrency : this . scannerCfg . CONCURRENCY_LIMIT ,
66
63
} ) ;
0 commit comments