11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciif (!common.hasCrypto) 61cb0ef41Sopenharmony_ci common.skip('missing crypto'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst tls = require('tls'); 91cb0ef41Sopenharmony_ciconst assert = require('assert'); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciconst cert = fixtures.readKey('rsa_cert.crt'); 121cb0ef41Sopenharmony_ciconst key = fixtures.readKey('rsa_private.pem'); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ci// https://github.com/nodejs/node/issues/1489 151cb0ef41Sopenharmony_ci// tls.connect(options) with no options.host should accept a cert with 161cb0ef41Sopenharmony_ci// CN:'localhost' 171cb0ef41Sopenharmony_ciconst server = tls.createServer({ 181cb0ef41Sopenharmony_ci key, 191cb0ef41Sopenharmony_ci cert 201cb0ef41Sopenharmony_ci}).listen(0, common.mustCall(function() { 211cb0ef41Sopenharmony_ci const socket = tls.connect({ 221cb0ef41Sopenharmony_ci port: this.address().port, 231cb0ef41Sopenharmony_ci ca: cert, 241cb0ef41Sopenharmony_ci // No host set here. 'localhost' is the default, 251cb0ef41Sopenharmony_ci // but tls.checkServerIdentity() breaks before the fix with: 261cb0ef41Sopenharmony_ci // Error: Hostname/IP doesn't match certificate's altnames: 271cb0ef41Sopenharmony_ci // "Host: undefined. is not cert's CN: localhost" 281cb0ef41Sopenharmony_ci }, common.mustCall(function() { 291cb0ef41Sopenharmony_ci assert(socket.authorized); 301cb0ef41Sopenharmony_ci socket.destroy(); 311cb0ef41Sopenharmony_ci server.close(); 321cb0ef41Sopenharmony_ci })); 331cb0ef41Sopenharmony_ci})); 34