11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciif (!common.hasCrypto) 71cb0ef41Sopenharmony_ci common.skip('missing crypto'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciconst tls = require('tls'); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ci// This test expects `tls.connect()` to emit a warning when 121cb0ef41Sopenharmony_ci// `servername` of options is an IP address. 131cb0ef41Sopenharmony_cicommon.expectWarning( 141cb0ef41Sopenharmony_ci 'DeprecationWarning', 151cb0ef41Sopenharmony_ci 'Setting the TLS ServerName to an IP address is not permitted by ' + 161cb0ef41Sopenharmony_ci 'RFC 6066. This will be ignored in a future version.', 171cb0ef41Sopenharmony_ci 'DEP0123' 181cb0ef41Sopenharmony_ci); 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ci{ 211cb0ef41Sopenharmony_ci const options = { 221cb0ef41Sopenharmony_ci key: fixtures.readKey('agent1-key.pem'), 231cb0ef41Sopenharmony_ci cert: fixtures.readKey('agent1-cert.pem') 241cb0ef41Sopenharmony_ci }; 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ci const server = tls.createServer(options, function(s) { 271cb0ef41Sopenharmony_ci s.end('hello'); 281cb0ef41Sopenharmony_ci }).listen(0, function() { 291cb0ef41Sopenharmony_ci const client = tls.connect({ 301cb0ef41Sopenharmony_ci port: this.address().port, 311cb0ef41Sopenharmony_ci rejectUnauthorized: false, 321cb0ef41Sopenharmony_ci servername: '127.0.0.1', 331cb0ef41Sopenharmony_ci }, function() { 341cb0ef41Sopenharmony_ci client.end(); 351cb0ef41Sopenharmony_ci }); 361cb0ef41Sopenharmony_ci }); 371cb0ef41Sopenharmony_ci 381cb0ef41Sopenharmony_ci server.on('connection', common.mustCall(function(socket) { 391cb0ef41Sopenharmony_ci server.close(); 401cb0ef41Sopenharmony_ci })); 411cb0ef41Sopenharmony_ci} 42