This repository has been archived by the owner on May 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #212 from pro-src/211_ssl_ciphers
Backport TLSv1.3 secure ciphers
- Loading branch information
Showing
3 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'use strict'; | ||
|
||
const tls = require('tls'); | ||
|
||
const ciphers = getCiphers(); | ||
|
||
if (ciphers !== -1) { | ||
module.exports.ciphers = ciphers; | ||
} | ||
|
||
function getCiphers () { | ||
// SSL_CTX_set_cipher_list will simply ignore any unsupported ciphers | ||
const defaults = [ | ||
'TLS_AES_128_CCM_8_SHA256', | ||
'TLS_AES_128_CCM_SHA256', | ||
'TLS_AES_128_GCM_SHA256', | ||
'TLS_AES_256_GCM_SHA384', | ||
'TLS_CHACHA20_POLY1305_SHA256' | ||
]; | ||
|
||
// We already have these defaults if using openssl v1.1.1 and later | ||
const v = process.versions.openssl.match(/(\d)+\.(\d+)\.(\d+)/); | ||
if (v[1] >= 1 && v[2] >= 1 && v[3] >= 1) { | ||
return -1; | ||
} | ||
|
||
const suites = tls.getCiphers() | ||
.map(function (s) { | ||
return s.toUpperCase(); | ||
}); | ||
|
||
let missing = false; | ||
// Add the default TLSv1.3 cipher suites if missing | ||
for (let i = 0; i < defaults.length; i++) { | ||
if (suites.indexOf(defaults[i]) === -1) { | ||
missing = true; | ||
suites.push(defaults[i]); | ||
} | ||
} | ||
|
||
return missing ? suites.join(':') : -1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters