Skip to content

Commit 7aeca27

Browse files
sam-githubBethGriggs
authored andcommitted
tls: supported shared openssl 1.1.0
PR-URL: #26951 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
1 parent fa6f0f1 commit 7aeca27

8 files changed

+35
-3
lines changed

lib/_tls_common.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function toV(which, v, def) {
4747
if (v === 'TLSv1') return TLS1_VERSION;
4848
if (v === 'TLSv1.1') return TLS1_1_VERSION;
4949
if (v === 'TLSv1.2') return TLS1_2_VERSION;
50-
if (v === 'TLSv1.3') return TLS1_3_VERSION;
50+
if (v === 'TLSv1.3' && TLS1_3_VERSION) return TLS1_3_VERSION;
5151
throw new ERR_TLS_INVALID_PROTOCOL_VERSION(v, which);
5252
}
5353

src/node_constants.cc

+2
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,9 @@ void DefineCryptoConstants(Local<Object> target) {
12451245
NODE_DEFINE_CONSTANT(target, TLS1_VERSION);
12461246
NODE_DEFINE_CONSTANT(target, TLS1_1_VERSION);
12471247
NODE_DEFINE_CONSTANT(target, TLS1_2_VERSION);
1248+
#ifdef TLS1_3_VERSION
12481249
NODE_DEFINE_CONSTANT(target, TLS1_3_VERSION);
1250+
#endif
12491251
#endif
12501252
NODE_DEFINE_CONSTANT(target, INT_MAX);
12511253
}

src/node_crypto.cc

+7-2
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,12 @@ void SecureContext::New(const FunctionCallbackInfo<Value>& args) {
411411

412412
// A maxVersion of 0 means "any", but OpenSSL may support TLS versions that
413413
// Node.js doesn't, so pin the max to what we do support.
414-
const int MAX_SUPPORTED_VERSION = TLS1_3_VERSION;
414+
const int MAX_SUPPORTED_VERSION =
415+
#ifdef TLS1_3_VERSION
416+
TLS1_3_VERSION;
417+
#else
418+
TLS1_2_VERSION;
419+
#endif
415420

416421
void SecureContext::Init(const FunctionCallbackInfo<Value>& args) {
417422
SecureContext* sc;
@@ -947,7 +952,7 @@ void SecureContext::AddRootCerts(const FunctionCallbackInfo<Value>& args) {
947952

948953
void SecureContext::SetCipherSuites(const FunctionCallbackInfo<Value>& args) {
949954
// BoringSSL doesn't allow API config of TLS1.3 cipher suites.
950-
#ifndef OPENSSL_IS_BORINGSSL
955+
#if defined(TLS1_3_VERSION) && !defined(OPENSSL_IS_BORINGSSL)
951956
SecureContext* sc;
952957
ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder());
953958
Environment* env = sc->env();

test/parallel/test-tls-client-renegotiation-13.js

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
const common = require('../common');
55
const fixtures = require('../common/fixtures');
66

7+
if (!require('constants').TLS1_3_VERSION)
8+
common.skip(`openssl ${process.versions.openssl} does not support TLSv1.3`);
9+
710
// Confirm that for TLSv1.3, renegotiate() is disallowed.
811

912
const {

test/parallel/test-tls-getcipher.js

+3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ server.listen(0, '127.0.0.1', common.mustCall(function() {
5656
}));
5757
}));
5858

59+
if (!require('constants').TLS1_3_VERSION)
60+
return console.log('cannot test TLSv1.3 against 1.3-incapable shared lib');
61+
5962
tls.createServer({
6063
key: fixtures.readKey('agent2-key.pem'),
6164
cert: fixtures.readKey('agent2-cert.pem'),

test/parallel/test-tls-min-max-version.js

+12
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,25 @@ const {
99
} = require(fixtures.path('tls-connect'));
1010
const DEFAULT_MIN_VERSION = tls.DEFAULT_MIN_VERSION;
1111
const DEFAULT_MAX_VERSION = tls.DEFAULT_MAX_VERSION;
12+
const tls13 = !!require('constants').TLS1_3_VERSION;
13+
14+
if (!tls13 && (
15+
DEFAULT_MAX_VERSION === 'TLSv1.3' ||
16+
DEFAULT_MIN_VERSION === 'TLSv1.3')) {
17+
return common.skip('cannot test TLSv1.3 against 1.3-incapable shared lib');
18+
}
1219

1320
function test(cmin, cmax, cprot, smin, smax, sprot, proto, cerr, serr) {
1421
assert(proto || cerr || serr, 'test missing any expectations');
1522
// Report where test was called from. Strip leading garbage from
1623
// at Object.<anonymous> (file:line)
1724
// from the stack location, we only want the file:line part.
1825
const where = (new Error()).stack.split('\n')[2].replace(/[^(]*/, '');
26+
if (Array.prototype.includes.call(arguments, 'TLSv1.3')) {
27+
console.log('test: skip because TLSv1.3 is not supported');
28+
console.log(' ', where);
29+
return;
30+
}
1931
connect({
2032
client: {
2133
checkServerIdentity: (servername, cert) => { },

test/parallel/test-tls-set-ciphers-error.js

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ const common = require('../common');
44
if (!common.hasCrypto)
55
common.skip('missing crypto');
66

7+
if (!require('constants').TLS1_3_VERSION)
8+
return common.skip('openssl before TLS1.3 does not check for failure');
9+
710
const assert = require('assert');
811
const tls = require('tls');
912
const fixtures = require('../common/fixtures');

test/parallel/test-tls-set-ciphers.js

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ if (tls13)
1515
tls.DEFAULT_MAX_VERSION = 'TLSv1.3';
1616

1717
function test(cciphers, sciphers, cipher, cerr, serr) {
18+
if (!tls13 && (/TLS_/.test(cciphers) || /TLS_/.test(sciphers))) {
19+
// Test relies on TLS1.3, skip it.
20+
return;
21+
}
1822
assert(cipher || cerr || serr, 'test missing any expectations');
1923
const where = (new Error()).stack.split('\n')[2].replace(/[^(]*/, '');
2024
connect({

0 commit comments

Comments
 (0)