2017-01-04 05: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 19:00:06 +08:00
|
|
|
'use strict';
|
2016-12-31 07:38:06 +08:00
|
|
|
const common = require('../common');
|
2015-03-04 09:11:21 +08:00
|
|
|
|
2017-07-01 07:29:09 +08:00
|
|
|
if (!common.hasCrypto)
|
2016-05-12 03:34:52 +08:00
|
|
|
common.skip('missing crypto');
|
2015-03-04 09:11:21 +08:00
|
|
|
|
2017-10-07 00:46:22 +08:00
|
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
|
2017-08-09 00:53:55 +08:00
|
|
|
const assert = require('assert');
|
|
|
|
const tls = require('tls');
|
2011-06-25 21:30:17 +08:00
|
|
|
|
2011-10-05 06:08:18 +08:00
|
|
|
// https://github.com/joyent/node/issues/1218
|
|
|
|
// uncatchable exception on TLS connection error
|
2016-07-13 07:47:32 +08:00
|
|
|
{
|
2019-05-30 02:43:44 +08:00
|
|
|
const cert = fixtures.readKey('rsa_cert.crt');
|
|
|
|
const key = fixtures.readKey('rsa_private.pem');
|
2011-06-25 21:30:17 +08:00
|
|
|
|
2017-07-11 08:55:21 +08:00
|
|
|
const options = { cert: cert, key: key, port: common.PORT };
|
2017-02-04 03:54:19 +08:00
|
|
|
const conn = tls.connect(options, common.mustNotCall());
|
2011-06-25 21:30:17 +08:00
|
|
|
|
2017-08-09 00:53:55 +08:00
|
|
|
conn.on(
|
|
|
|
'error',
|
|
|
|
common.mustCall((e) => { assert.strictEqual(e.code, 'ECONNREFUSED'); })
|
|
|
|
);
|
2016-07-13 07:47:32 +08:00
|
|
|
}
|
2013-11-13 20:58:46 +08:00
|
|
|
|
|
|
|
// SSL_accept/SSL_connect error handling
|
2016-07-13 07:47:32 +08:00
|
|
|
{
|
2019-05-30 02:43:44 +08:00
|
|
|
const cert = fixtures.readKey('rsa_cert.crt');
|
|
|
|
const key = fixtures.readKey('rsa_private.pem');
|
2013-11-13 20:58:46 +08:00
|
|
|
|
2018-06-27 15:08:06 +08:00
|
|
|
assert.throws(() => {
|
|
|
|
tls.connect({
|
|
|
|
cert: cert,
|
|
|
|
key: key,
|
|
|
|
port: common.PORT,
|
|
|
|
ciphers: 'rick-128-roll'
|
|
|
|
}, common.mustNotCall());
|
|
|
|
}, /no cipher match/i);
|
2016-07-13 07:47:32 +08:00
|
|
|
}
|