https: do not automatically use invalid servername · nodejs/node@53cc16c · GitHub
Skip to content

Commit 53cc16c

Browse files
sam-githubBridgeAR
authored andcommitted
https: do not automatically use invalid servername
Stop automatically setting servername in https.request() if the target host is specified with an IP address. Doing so is invalid, and triggers a deprecation warning. It is still possible to send an IP address as a servername if its required, but it needs to be explicity configured, it won't happen automatically. PR-URL: #28209 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 5fddde6 commit 53cc16c

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

doc/api/https.md

Lines changed: 10 additions & 2 deletions

lib/_http_agent.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ function calculateServerName(options, req) {
256256
servername = hostHeader.split(':', 1)[0];
257257
}
258258
}
259+
// Don't implicitly set invalid (IP) servernames.
260+
if (net.isIP(servername))
261+
servername = '';
259262
return servername;
260263
}
261264

test/parallel/test-https-simple.js

Lines changed: 3 additions & 0 deletions

0 commit comments

Comments
 (0)