GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tls_wrap: use localhost if options.host is empty · Fishrock123/node@a7d7463

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • _tls_wrap.js
  • test/parallel
    • test-tls-connect-no-host.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/_tls_wrap.js‎

Copy file name to clipboardExpand all lines: lib/_tls_wrap.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,8 @@ exports.connect = function(/* [port, host], options, cb */) {
858858

859859
var hostname = options.servername ||
860860
options.host ||
861-
options.socket && options.socket._host,
861+
(options.socket && options.socket._host) ||
862+
'localhost',
862863
NPN = {},
863864
context = tls.createSecureContext(options);
864865
tls.convertNPNProtocols(options.NPNProtocols, NPN);
Collapse file

‎test/parallel/test-tls-connect-no-host.js‎

Copy file name to clipboard
+34Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
var common = require('../common');
2+
3+
if (!common.hasCrypto) {
4+
console.log('1..0 # Skipped: missing crypto');
5+
process.exit();
6+
}
7+
var tls = require('tls');
8+
9+
var assert = require('assert');
10+
var fs = require('fs');
11+
var path = require('path');
12+
13+
var cert = fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'));
14+
var key = fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem'));
15+
16+
// https://github.com/iojs/io.js/issues/1489
17+
// tls.connect(options) with no options.host should accept a cert with
18+
// CN:'localhost'
19+
tls.createServer({
20+
key: key,
21+
cert: cert
22+
}).listen(common.PORT);
23+
24+
var socket = tls.connect({
25+
port: common.PORT,
26+
ca: cert,
27+
// No host set here. 'localhost' is the default,
28+
// but tls.checkServerIdentity() breaks before the fix with:
29+
// Error: Hostname/IP doesn't match certificate's altnames:
30+
// "Host: undefined. is not cert's CN: localhost"
31+
}, function() {
32+
assert(socket.authorized);
33+
process.exit();
34+
});

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.