Skip to content

Commit

Permalink
Add support for strict-ssl config (#1025)
Browse files Browse the repository at this point in the history
* Fixed config resolution

* Added support for disabling strict ssl

* Fixed flow errors
  • Loading branch information
TAGraves authored and Sebastian McKenzie committed Oct 15, 2016
1 parent 73251d4 commit b0611a6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')),
});
}

Expand Down
1 change: 1 addition & 0 deletions src/registries/yarn-registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/?',
Expand Down
11 changes: 10 additions & 1 deletion src/util/request-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type RequestParams<T> = {
proxy?: string,
encoding?: ?string,
forever?: boolean,
strictSSL?: boolean,
headers?: {
[name: string]: string
},
Expand Down Expand Up @@ -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;
Expand All @@ -82,6 +84,7 @@ export default class RequestManager {
running: number;
httpsProxy: ?string;
httpProxy: ?string;
strictSSL: boolean;
offlineQueue: Array<RequestOptions>;
queue: Array<Object>;
max: number;
Expand All @@ -98,6 +101,7 @@ export default class RequestManager {
captureHar?: boolean,
httpProxy?: string,
httpsProxy?: string,
strictSSL?: boolean,
}) {
if (opts.userAgent != null) {
this.userAgent = opts.userAgent;
Expand All @@ -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;
}
}

/**
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit b0611a6

Please sign in to comment.