2015-05-19 19:00:06 +08:00
|
|
|
'use strict';
|
2016-05-14 14:01:25 +08:00
|
|
|
const common = require('../common');
|
2013-10-28 18:25:27 +08:00
|
|
|
|
2015-03-04 09:11:21 +08:00
|
|
|
if (!common.hasCrypto) {
|
2016-05-12 03:34:52 +08:00
|
|
|
common.skip('missing crypto');
|
2015-07-07 23:25:55 +08:00
|
|
|
return;
|
2015-03-04 09:11:21 +08:00
|
|
|
}
|
2016-05-14 14:01:25 +08:00
|
|
|
const tls = require('tls');
|
2015-03-04 09:11:21 +08:00
|
|
|
|
2016-05-14 14:01:25 +08:00
|
|
|
const net = require('net');
|
2013-10-28 18:25:27 +08:00
|
|
|
|
2016-05-14 14:01:25 +08:00
|
|
|
const socket = net.connect(443, 'www.example.org', common.mustCall(() => {
|
|
|
|
const secureSocket = tls.connect({socket: socket}, common.mustCall(() => {
|
2013-10-28 18:25:27 +08:00
|
|
|
secureSocket.destroy();
|
2016-05-14 14:01:25 +08:00
|
|
|
console.log('ok');
|
|
|
|
}));
|
|
|
|
}));
|