-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Accept the maxVersion and minVersion properties in connection ssl option
- Loading branch information
1 parent
281d935
commit dc9c152
Showing
7 changed files
with
180 additions
and
1 deletion.
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
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
42 changes: 42 additions & 0 deletions
42
test/unit/connection/test-connection-ssl-max-version-accept.js
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 @@ | ||
var assert = require('assert'); | ||
var common = require('../../common'); | ||
var tls = require('tls'); | ||
|
||
if (!tls.createSecureContext) { | ||
common.skipTest('node ' + process.version + ' does not support tls.createSecureContext()'); | ||
} | ||
|
||
if (!tls.DEFAULT_MAX_VERSION) { | ||
common.skipTest('node ' + process.version + ' does not support tls maxVersion'); | ||
} | ||
|
||
var server = common.createFakeServer({ | ||
ssl: { | ||
maxVersion : tls.DEFAULT_MAX_VERSION, | ||
minVersion : tls.DEFAULT_MAX_VERSION | ||
} | ||
}); | ||
|
||
server.listen(0, function (err) { | ||
assert.ifError(err); | ||
|
||
var connection = common.createConnection({ | ||
port : server.port(), | ||
ssl : { | ||
ca : common.getSSLConfig().ca, | ||
maxVersion : tls.DEFAULT_MAX_VERSION | ||
} | ||
}); | ||
|
||
connection.connect(function (err) { | ||
assert.ifError(err); | ||
connection.destroy(); | ||
server.destroy(); | ||
}); | ||
}); | ||
|
||
server.on('connection', function (incomingConnection) { | ||
incomingConnection.handshake({ | ||
serverCapabilities1: common.ClientConstants.CLIENT_SSL | ||
}); | ||
}); |
44 changes: 44 additions & 0 deletions
44
test/unit/connection/test-connection-ssl-max-version-reject.js
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,44 @@ | ||
var assert = require('assert'); | ||
var common = require('../../common'); | ||
var tls = require('tls'); | ||
|
||
if (!tls.createSecureContext) { | ||
common.skipTest('node ' + process.version + ' does not support tls.createSecureContext()'); | ||
} | ||
|
||
if (!tls.DEFAULT_MAX_VERSION) { | ||
common.skipTest('node ' + process.version + ' does not support tls maxVersion'); | ||
} | ||
|
||
var server = common.createFakeServer({ | ||
ssl: { | ||
maxVersion : tls.DEFAULT_MAX_VERSION, | ||
minVersion : tls.DEFAULT_MAX_VERSION | ||
} | ||
}); | ||
|
||
server.listen(0, function (err) { | ||
assert.ifError(err); | ||
|
||
var connection = common.createConnection({ | ||
port : server.port(), | ||
ssl : { | ||
ca : common.getSSLConfig().ca, | ||
maxVersion : tls.DEFAULT_MIN_VERSION | ||
} | ||
}); | ||
|
||
connection.connect(function (err) { | ||
assert.ok(err); | ||
assert.strictEqual(err.code, 'HANDSHAKE_SSL_ERROR'); | ||
assert.strictEqual(err.fatal, true); | ||
connection.destroy(); | ||
server.destroy(); | ||
}); | ||
}); | ||
|
||
server.on('connection', function (incomingConnection) { | ||
incomingConnection.handshake({ | ||
serverCapabilities1: common.ClientConstants.CLIENT_SSL | ||
}); | ||
}); |
42 changes: 42 additions & 0 deletions
42
test/unit/connection/test-connection-ssl-min-version-accept.js
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 @@ | ||
var assert = require('assert'); | ||
var common = require('../../common'); | ||
var tls = require('tls'); | ||
|
||
if (!tls.createSecureContext) { | ||
common.skipTest('node ' + process.version + ' does not support tls.createSecureContext()'); | ||
} | ||
|
||
if (!tls.DEFAULT_MIN_VERSION) { | ||
common.skipTest('node ' + process.version + ' does not support tls minVersion'); | ||
} | ||
|
||
var server = common.createFakeServer({ | ||
ssl: { | ||
maxVersion : tls.DEFAULT_MIN_VERSION, | ||
minVersion : tls.DEFAULT_MIN_VERSION | ||
} | ||
}); | ||
|
||
server.listen(0, function (err) { | ||
assert.ifError(err); | ||
|
||
var connection = common.createConnection({ | ||
port : server.port(), | ||
ssl : { | ||
ca : common.getSSLConfig().ca, | ||
minVersion : tls.DEFAULT_MIN_VERSION | ||
} | ||
}); | ||
|
||
connection.connect(function (err) { | ||
assert.ifError(err); | ||
connection.destroy(); | ||
server.destroy(); | ||
}); | ||
}); | ||
|
||
server.on('connection', function (incomingConnection) { | ||
incomingConnection.handshake({ | ||
serverCapabilities1: common.ClientConstants.CLIENT_SSL | ||
}); | ||
}); |
44 changes: 44 additions & 0 deletions
44
test/unit/connection/test-connection-ssl-min-version-reject.js
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,44 @@ | ||
var assert = require('assert'); | ||
var common = require('../../common'); | ||
var tls = require('tls'); | ||
|
||
if (!tls.createSecureContext) { | ||
common.skipTest('node ' + process.version + ' does not support tls.createSecureContext()'); | ||
} | ||
|
||
if (!tls.DEFAULT_MIN_VERSION) { | ||
common.skipTest('node ' + process.version + ' does not support tls minVersion'); | ||
} | ||
|
||
var server = common.createFakeServer({ | ||
ssl: { | ||
maxVersion : tls.DEFAULT_MIN_VERSION, | ||
minVersion : tls.DEFAULT_MIN_VERSION | ||
} | ||
}); | ||
|
||
server.listen(0, function (err) { | ||
assert.ifError(err); | ||
|
||
var connection = common.createConnection({ | ||
port : server.port(), | ||
ssl : { | ||
ca : common.getSSLConfig().ca, | ||
minVersion : tls.DEFAULT_MAX_VERSION | ||
} | ||
}); | ||
|
||
connection.connect(function (err) { | ||
assert.ok(err); | ||
assert.strictEqual(err.code, 'HANDSHAKE_SSL_ERROR'); | ||
assert.strictEqual(err.fatal, true); | ||
connection.destroy(); | ||
server.destroy(); | ||
}); | ||
}); | ||
|
||
server.on('connection', function (incomingConnection) { | ||
incomingConnection.handshake({ | ||
serverCapabilities1: common.ClientConstants.CLIENT_SSL | ||
}); | ||
}); |