1'use strict'; 2 3const common = require('../common'); 4const fixtures = require('../common/fixtures'); 5 6if (!common.hasCrypto) 7 common.skip('missing crypto'); 8 9const tls = require('tls'); 10 11// This test expects `tls.connect()` to emit a warning when 12// `servername` of options is an IP address. 13common.expectWarning( 14 'DeprecationWarning', 15 'Setting the TLS ServerName to an IP address is not permitted by ' + 16 'RFC 6066. This will be ignored in a future version.', 17 'DEP0123' 18); 19 20{ 21 const options = { 22 key: fixtures.readKey('agent1-key.pem'), 23 cert: fixtures.readKey('agent1-cert.pem') 24 }; 25 26 const server = tls.createServer(options, function(s) { 27 s.end('hello'); 28 }).listen(0, function() { 29 const client = tls.connect({ 30 port: this.address().port, 31 rejectUnauthorized: false, 32 servername: '127.0.0.1', 33 }, function() { 34 client.end(); 35 }); 36 }); 37 38 server.on('connection', common.mustCall(function(socket) { 39 server.close(); 40 })); 41} 42