Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b64ce59

Browse filesBrowse files
Myles Borinsrvagg
authored andcommitted
tls: remove util and calls to util.format
Currently util.format is being used for string templating in tls. By replacing all of the instances of util.format with backtick string we can remove the need to require util in tls all together. PR-URL: #3456 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Fedor Indutny <fedor@indutny.com>
1 parent f236b3a commit b64ce59
Copy full SHA for b64ce59

File tree

Expand file treeCollapse file tree

1 file changed

+6
-12
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-12
lines changed
Open diff view settings
Collapse file

‎lib/tls.js‎

Copy file name to clipboardExpand all lines: lib/tls.js
+6-12Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
const net = require('net');
44
const url = require('url');
5-
const util = require('util');
65
const binding = process.binding('crypto');
76
const Buffer = require('buffer').Buffer;
87
const constants = require('constants');
@@ -141,9 +140,7 @@ exports.checkServerIdentity = function checkServerIdentity(host, cert) {
141140
return ip === host;
142141
});
143142
if (!valid) {
144-
reason = util.format('IP: %s is not in the cert\'s list: %s',
145-
host,
146-
ips.join(', '));
143+
reason = `IP: ${host} is not in the cert's list: ${ips.join(', ')}`;
147144
}
148145
} else if (cert.subject) {
149146
// Transform hostname to canonical form
@@ -189,13 +186,11 @@ exports.checkServerIdentity = function checkServerIdentity(host, cert) {
189186

190187
if (!valid) {
191188
if (cert.subjectaltname) {
192-
reason = util.format('Host: %s is not in the cert\'s altnames: %s',
193-
host,
194-
cert.subjectaltname);
189+
reason =
190+
`Host: ${host} is not in the cert's altnames: ` +
191+
`${cert.subjectaltname}`;
195192
} else {
196-
reason = util.format('Host: %s is not cert\'s CN: %s',
197-
host,
198-
cert.subject.CN);
193+
reason = `Host: ${host} is not cert's CN: ${cert.subject.CN}`;
199194
}
200195
}
201196
} else {
@@ -204,8 +199,7 @@ exports.checkServerIdentity = function checkServerIdentity(host, cert) {
204199

205200
if (!valid) {
206201
var err = new Error(
207-
util.format('Hostname/IP doesn\'t match certificate\'s altnames: %j',
208-
reason));
202+
`Hostname/IP doesn't match certificate's altnames: "${reason}"`);
209203
err.reason = reason;
210204
err.host = host;
211205
err.cert = cert;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.