-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http, tls: better support for IPv6 addresses
- Properly handle IPv6 in Host header when setting servername. - When comparing IP addresses against addresses in the subjectAltName field of a certificate, format the address correctly before doing the string comparison. PR-URL: #14772 Fixes: #14736 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
1 parent
a0b94f4
commit d6d4610
Showing
4 changed files
with
83 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict'; | ||
require('../common'); | ||
|
||
// Test conversion of IP addresses to the format returned | ||
// for addresses in Subject Alternative Name section | ||
// of a TLS certificate | ||
|
||
const assert = require('assert'); | ||
const { canonicalizeIP } = process.binding('cares_wrap'); | ||
|
||
assert.strictEqual(canonicalizeIP('127.0.0.1'), '127.0.0.1'); | ||
assert.strictEqual(canonicalizeIP('10.1.0.1'), '10.1.0.1'); | ||
assert.strictEqual(canonicalizeIP('::1'), '::1'); | ||
assert.strictEqual(canonicalizeIP('fe80:0:0:0:0:0:0:1'), 'fe80::1'); | ||
assert.strictEqual(canonicalizeIP('fe80:0:0:0:0:0:0:0'), 'fe80::'); | ||
assert.strictEqual(canonicalizeIP('fe80::0000:0010:0001'), 'fe80::10:1'); | ||
assert.strictEqual(canonicalizeIP('0001:2222:3333:4444:5555:6666:7777:0088'), | ||
'1:2222:3333:4444:5555:6666:7777:88'); | ||
|
||
assert.strictEqual(canonicalizeIP('0001:2222:3333:4444:5555:6666::'), | ||
'1:2222:3333:4444:5555:6666::'); | ||
|
||
assert.strictEqual(canonicalizeIP('a002:B12:00Ba:4444:5555:6666:0:0'), | ||
'a002:b12:ba:4444:5555:6666::'); | ||
|
||
// IPv4 address represented in IPv6 | ||
assert.strictEqual(canonicalizeIP('0:0:0:0:0:ffff:c0a8:101'), | ||
'::ffff:192.168.1.1'); | ||
|
||
assert.strictEqual(canonicalizeIP('::ffff:192.168.1.1'), | ||
'::ffff:192.168.1.1'); |