2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2011-06-25 15:30:17 +02:00
|
|
|
var common = require('../common');
|
|
|
|
var assert = require('assert');
|
2015-03-04 12:11:21 +11:00
|
|
|
|
|
|
|
if (!common.hasCrypto) {
|
|
|
|
console.log('1..0 # Skipped: missing crypto');
|
2015-07-07 20:55:55 +05:30
|
|
|
return;
|
2015-03-04 12:11:21 +11:00
|
|
|
}
|
2011-06-25 15:30:17 +02:00
|
|
|
var tls = require('tls');
|
2015-03-04 12:11:21 +11:00
|
|
|
|
|
|
|
var fs = require('fs');
|
2011-06-25 15:30:17 +02:00
|
|
|
var path = require('path');
|
|
|
|
|
2011-10-04 18:08:18 -04:00
|
|
|
// https://github.com/joyent/node/issues/1218
|
|
|
|
// uncatchable exception on TLS connection error
|
2011-06-25 15:30:17 +02:00
|
|
|
(function() {
|
|
|
|
var cert = fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'));
|
|
|
|
var key = fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem'));
|
|
|
|
|
|
|
|
var errorEmitted = false;
|
|
|
|
|
|
|
|
process.on('exit', function() {
|
|
|
|
assert.ok(errorEmitted);
|
|
|
|
});
|
|
|
|
|
2011-11-01 16:28:04 +01:00
|
|
|
var conn = tls.connect({cert: cert, key: key, port: common.PORT}, function() {
|
2011-06-25 15:30:17 +02:00
|
|
|
assert.ok(false); // callback should never be executed
|
|
|
|
});
|
|
|
|
|
|
|
|
conn.on('error', function() {
|
|
|
|
errorEmitted = true;
|
|
|
|
});
|
|
|
|
})();
|
2013-11-13 16:58:46 +04:00
|
|
|
|
|
|
|
// SSL_accept/SSL_connect error handling
|
|
|
|
(function() {
|
|
|
|
var cert = fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'));
|
|
|
|
var key = fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem'));
|
|
|
|
|
|
|
|
var errorEmitted = false;
|
|
|
|
|
|
|
|
process.on('exit', function() {
|
|
|
|
assert.ok(errorEmitted);
|
|
|
|
});
|
|
|
|
|
|
|
|
var conn = tls.connect({
|
|
|
|
cert: cert,
|
|
|
|
key: key,
|
|
|
|
port: common.PORT,
|
|
|
|
ciphers: 'rick-128-roll'
|
|
|
|
}, function() {
|
|
|
|
assert.ok(false); // callback should never be executed
|
|
|
|
});
|
|
|
|
|
|
|
|
conn.on('error', function() {
|
|
|
|
errorEmitted = true;
|
|
|
|
});
|
|
|
|
})();
|