This repository was archived by the owner on May 9, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +49
-2
lines changed
Expand file tree Collapse file tree 3 files changed +49
-2
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ const requestModule = require('request-promise');
44const sandbox = require ( './lib/sandbox' ) ;
55const decodeEmails = require ( './lib/email-decode.js' ) ;
66const getDefaultHeaders = require ( './lib/headers' ) ;
7+ const agentOptions = require ( './lib/agent-options' ) ;
78const brotli = require ( './lib/brotli' ) ;
89
910const {
@@ -35,7 +36,9 @@ function defaults (params) {
3536 // Remove Cloudflare's email protection
3637 decodeEmails : false ,
3738 // Support gzip encoded responses
38- gzip : true
39+ gzip : true ,
40+ // Adds secure TLSv1.3 ciphers when using older openssl versions
41+ agentOptions
3942 } ;
4043
4144 // Object.assign requires at least nodejs v4, request only test/supports v6+
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ const tls = require ( 'tls' ) ;
4+
5+ const ciphers = getCiphers ( ) ;
6+
7+ if ( ciphers !== - 1 ) {
8+ module . exports . ciphers = ciphers ;
9+ }
10+
11+ function getCiphers ( ) {
12+ // SSL_CTX_set_cipher_list will simply ignore any unsupported ciphers
13+ const defaults = [
14+ 'TLS_AES_128_CCM_8_SHA256' ,
15+ 'TLS_AES_128_CCM_SHA256' ,
16+ 'TLS_AES_128_GCM_SHA256' ,
17+ 'TLS_AES_256_GCM_SHA384' ,
18+ 'TLS_CHACHA20_POLY1305_SHA256'
19+ ] ;
20+
21+ // We already have these defaults if using openssl v1.1.1 and later
22+ const v = process . versions . openssl . match ( / ( \d ) + \. ( \d + ) \. ( \d + ) / ) ;
23+ if ( v [ 1 ] >= 1 && v [ 2 ] >= 1 && v [ 3 ] >= 1 ) {
24+ return - 1 ;
25+ }
26+
27+ const suites = tls . getCiphers ( )
28+ . map ( function ( s ) {
29+ return s . toUpperCase ( ) ;
30+ } ) ;
31+
32+ let missing = false ;
33+ // Add the default TLSv1.3 cipher suites if missing
34+ for ( let i = 0 ; i < defaults . length ; i ++ ) {
35+ if ( suites . indexOf ( defaults [ i ] ) === - 1 ) {
36+ missing = true ;
37+ suites . push ( defaults [ i ] ) ;
38+ }
39+ }
40+
41+ return missing ? suites . join ( ':' ) : - 1 ;
42+ }
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ var express = require('express');
77
88// Clone the default headers for tests
99var defaultHeaders = Object . assign ( { } , require ( '../' ) . defaultParams . headers ) ;
10+ var agentOptions = require ( '../lib/agent-options' ) ;
1011
1112// Cache fixtures so they're only read from fs but once
1213var cache = { } ;
@@ -31,7 +32,8 @@ var helper = {
3132 cloudflareMaxTimeout : 30000 ,
3233 challengesToSolve : 3 ,
3334 decodeEmails : false ,
34- gzip : true
35+ gzip : true ,
36+ agentOptions
3537 } ;
3638 } ,
3739 getFixture : function ( fileName ) {
You can’t perform that action at this time.
0 commit comments