diff --git a/src/config.js b/src/config.js index f6e4373b2c..118840406b 100644 --- a/src/config.js +++ b/src/config.js @@ -163,6 +163,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 4747500895..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/?', @@ -56,14 +57,22 @@ export default class YarnRegistry extends NpmRegistry { homeConfig: Object; getOption(key: string): mixed { - let val = this.config[key] || this.registries.npm.getOption(npmMap[key]); + let val = this.config[key]; - // if we have no yarn option for this or have used a default then use the npm - // value if it exists - if (!val || val === DEFAULTS[key]) { - val = this.registries.npm.getOption(key) || val; + // if this isn't set in a yarn config, then use npm + if (typeof val === 'undefined') { + val = this.registries.npm.getOption(npmMap[key]); } + if (typeof val === 'undefined') { + val = this.registries.npm.getOption(key); + } + + // if this isn't set in a yarn config or npm config, then use the default (or undefined) + if (typeof val === 'undefined') { + val = DEFAULTS[key]; + } + return val; } 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);