diff --git a/src/config.js b/src/config.js index a5ec06a610..43cb91346d 100644 --- a/src/config.js +++ b/src/config.js @@ -183,6 +183,7 @@ export default class Config { userAgent: String(this.getOption('user-agent')), httpProxy: String(this.getOption('proxy') || ''), httpsProxy: String(this.getOption('https-proxy') || ''), + strictSSL: Boolean(this.getOption('strict-ssl')), }); } diff --git a/src/registries/yarn-registry.js b/src/registries/yarn-registry.js index 110391e781..95492c5cf9 100644 --- a/src/registries/yarn-registry.js +++ b/src/registries/yarn-registry.js @@ -26,6 +26,7 @@ export const DEFAULTS = { 'ignore-scripts': false, 'ignore-optional': false, registry: YARN_REGISTRY, + 'strict-ssl': true, 'user-agent': [ `yarn/${pkg.version}`, 'npm/?', diff --git a/src/util/request-manager.js b/src/util/request-manager.js index c8939662ef..0e66a11e87 100644 --- a/src/util/request-manager.js +++ b/src/util/request-manager.js @@ -40,6 +40,7 @@ type RequestParams = { proxy?: string, encoding?: ?string, forever?: boolean, + strictSSL?: boolean, headers?: { [name: string]: string }, @@ -67,6 +68,7 @@ export default class RequestManager { this.captureHar = false; this.httpsProxy = null; this.httpProxy = null; + this.strictSSL = true; this.userAgent = ''; this.reporter = reporter; this.running = 0; @@ -82,6 +84,7 @@ export default class RequestManager { running: number; httpsProxy: ?string; httpProxy: ?string; + strictSSL: boolean; offlineQueue: Array; queue: Array; max: number; @@ -98,6 +101,7 @@ export default class RequestManager { captureHar?: boolean, httpProxy?: string, httpsProxy?: string, + strictSSL?: boolean, }) { if (opts.userAgent != null) { this.userAgent = opts.userAgent; @@ -118,6 +122,10 @@ export default class RequestManager { if (opts.httpsProxy != null) { this.httpsProxy = opts.httpsProxy; } + + if (opts.strictSSL !== null && typeof opts.strictSSL !== 'undefined') { + this.strictSSL = opts.strictSSL; + } } /** @@ -155,7 +163,8 @@ export default class RequestManager { params.method = params.method || 'GET'; params.forever = true; params.retryAttempts = 0; - + params.strictSSL = this.strictSSL; + params.headers = Object.assign({ 'User-Agent': this.userAgent, }, params.headers);