Skip to content

Commit

Permalink
Enable more HTTPS options
Browse files Browse the repository at this point in the history
Related with #1306
TODO: tests
  • Loading branch information
szmarczak committed Apr 26, 2021
1 parent e830077 commit 83575d5
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
43 changes: 42 additions & 1 deletion source/core/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,16 @@ export interface HttpsOptions {
*/
passphrase?: SecureContextOptions['passphrase'];
pfx?: SecureContextOptions['pfx'];

ciphers?: SecureContextOptions['ciphers'];
honorCipherOrder?: SecureContextOptions['honorCipherOrder'];
minVersion?: SecureContextOptions['minVersion'];
maxVersion?: SecureContextOptions['maxVersion'];
signatureAlgorithms?: SecureContextOptions['sigalgs'];
tlsSessionLifetime?: SecureContextOptions['sessionTimeout'];
dhparam?: SecureContextOptions['dhparam'];
ecdhCurve?: SecureContextOptions['ecdhCurve'];
certificateRevocationLists?: SecureContextOptions['crl'];
}

export interface PaginateData<BodyType, ElementType> {
Expand Down Expand Up @@ -639,7 +649,16 @@ const defaultInternals: Options['_internals'] = {
key: undefined,
certificate: undefined,
passphrase: undefined,
pfx: undefined
pfx: undefined,
ciphers: undefined,
honorCipherOrder: undefined,
minVersion: undefined,
maxVersion: undefined,
signatureAlgorithms: undefined,
tlsSessionLifetime: undefined,
dhparam: undefined,
ecdhCurve: undefined,
certificateRevocationLists: undefined
},
encoding: undefined,
resolveBodyOnly: false,
Expand Down Expand Up @@ -1900,6 +1919,15 @@ export default class Options {
assert.any([is.string, is.undefined], value.passphrase);
assert.any([is.string, is.buffer, is.array, is.undefined], value.pfx);
assert.any([is.array, is.undefined], value.alpnProtocols);
assert.any([is.string, is.undefined], value.ciphers);
assert.any([is.string, is.buffer, is.undefined], value.dhparam);
assert.any([is.string, is.undefined], value.signatureAlgorithms);
assert.any([is.string, is.undefined], value.minVersion);
assert.any([is.string, is.undefined], value.maxVersion);
assert.any([is.boolean, is.undefined], value.honorCipherOrder);
assert.any([is.number, is.undefined], value.tlsSessionLifetime);
assert.any([is.string, is.undefined], value.ecdhCurve);
assert.any([is.string, is.buffer, is.array, is.undefined], value.certificateRevocationLists);

for (const key in value) {
if (!(key in this._internals.httpsOptions)) {
Expand Down Expand Up @@ -2082,13 +2110,26 @@ export default class Options {
return {
...internals.cacheOptions,
...this._unixOptions,

// HTTPS options
ca: httpsOptions.certificateAuthority,
cert: httpsOptions.certificate,
key: httpsOptions.key,
passphrase: httpsOptions.passphrase,
pfx: httpsOptions.pfx,
rejectUnauthorized: httpsOptions.rejectUnauthorized,
checkServerIdentity: httpsOptions.checkServerIdentity ?? checkServerIdentity,
ciphers: httpsOptions.ciphers,
honorCipherOrder: httpsOptions.honorCipherOrder,
minVersion: httpsOptions.minVersion,
maxVersion: httpsOptions.maxVersion,
sigalgs: httpsOptions.signatureAlgorithms,
sessionTimeout: httpsOptions.tlsSessionLifetime,
dhparam: httpsOptions.dhparam,
ecdhCurve: httpsOptions.ecdhCurve,
crl: httpsOptions.certificateRevocationLists,

// HTTP options
lookup: internals.dnsLookup ?? (internals.dnsCache as CacheableLookup | undefined)?.lookup,
family: internals.dnsLookupIpVersion,
agent,
Expand Down
3 changes: 3 additions & 0 deletions test/arguments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ test('prefixUrl is properly replaced when extending', withServer, async (t, serv
});

test('throws on too large noise', t => {
/* eslint-disable no-new */
t.throws(() => {
new Options({
retry: {
Expand Down Expand Up @@ -606,4 +607,6 @@ test('throws on too large noise', t => {
}
});
});

/* eslint-enable no-new */
});

0 comments on commit 83575d5

Please sign in to comment.