2017-01-03 13:16:48 -08:00
|
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the
|
|
|
|
// "Software"), to deal in the Software without restriction, including
|
|
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
|
|
// following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included
|
|
|
|
// in all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-12-30 18:38:06 -05:00
|
|
|
const common = require('../common');
|
2025-01-24 16:58:32 -08:00
|
|
|
if (!common.hasCrypto) {
|
2017-07-01 02:29:09 +03:00
|
|
|
common.skip('missing crypto');
|
2025-01-24 16:58:32 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
const {
|
|
|
|
hasOpenSSL,
|
|
|
|
opensslCli,
|
|
|
|
} = require('../common/crypto');
|
2014-07-17 23:01:40 +09:00
|
|
|
|
2025-01-24 16:58:32 -08:00
|
|
|
if (!opensslCli) {
|
2016-05-11 15:34:52 -04:00
|
|
|
common.skip('node compiled without OpenSSL CLI.');
|
2025-01-24 16:58:32 -08:00
|
|
|
}
|
2015-03-04 12:11:21 +11:00
|
|
|
|
2017-06-30 20:52:53 +03:00
|
|
|
const assert = require('assert');
|
2023-02-25 19:19:19 +01:00
|
|
|
const { execFile } = require('child_process');
|
2017-06-30 20:52:53 +03:00
|
|
|
const tls = require('tls');
|
2017-07-17 15:33:46 -07:00
|
|
|
const fixtures = require('../common/fixtures');
|
2014-07-17 23:01:40 +09:00
|
|
|
|
|
|
|
function loadPEM(n) {
|
2017-07-17 15:33:46 -07:00
|
|
|
return fixtures.readKey(`${n}.pem`);
|
2014-07-17 23:01:40 +09:00
|
|
|
}
|
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
const server = tls.Server({
|
2014-07-17 23:01:40 +09:00
|
|
|
secureProtocol: 'TLSv1_2_server_method',
|
|
|
|
key: loadPEM('agent2-key'),
|
2016-05-04 22:20:27 -07:00
|
|
|
cert: loadPEM('agent2-cert')
|
2023-02-25 19:19:19 +01:00
|
|
|
}, null).listen(0, common.mustCall(() => {
|
2017-01-08 13:19:00 +00:00
|
|
|
const args = ['s_client', '-quiet', '-tls1_1',
|
2025-01-24 16:58:32 -08:00
|
|
|
'-cipher', (hasOpenSSL(3, 1) ? 'DEFAULT:@SECLEVEL=0' : 'DEFAULT'),
|
2023-02-25 19:19:19 +01:00
|
|
|
'-connect', `127.0.0.1:${server.address().port}`];
|
2015-07-18 11:59:55 +09:00
|
|
|
|
2025-01-24 16:58:32 -08:00
|
|
|
execFile(opensslCli, args, common.mustCall((err, _, stderr) => {
|
2023-02-25 19:19:19 +01:00
|
|
|
assert.strictEqual(err.code, 1);
|
|
|
|
assert.match(stderr, /SSL alert number 70/);
|
|
|
|
server.close();
|
|
|
|
}));
|
|
|
|
}));
|