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 7165254

Browse filesBrowse files
bnoordhuisBridgeAR
authored andcommitted
test: more tls hostname verification coverage
Add some additional tests that check the interaction of an IP address as the Common Name and the presence (or lack of presence) of DNS, URI, and IP Address Subject Alternative Names. PR-URL: #27999 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
1 parent dfbbfbb commit 7165254
Copy full SHA for 7165254

File tree

Expand file treeCollapse file tree

1 file changed

+42
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+42
-0
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-tls-check-server-identity.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-tls-check-server-identity.js
+42Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,48 @@ const tests = [
7070
error: 'Host: a.com. is not cert\'s CN: .a.com'
7171
},
7272

73+
// IP address in CN. Technically allowed but so rare that we reject
74+
// it anyway. If we ever do start allowing them, we should take care
75+
// to only allow public (non-internal, non-reserved) IP addresses,
76+
// because that's what the spec mandates.
77+
{
78+
host: '8.8.8.8',
79+
cert: { subject: { CN: '8.8.8.8' } },
80+
error: 'IP: 8.8.8.8 is not in the cert\'s list: '
81+
},
82+
83+
// The spec suggests that a "DNS:" Subject Alternative Name containing an
84+
// IP address is valid but it seems so suspect that we currently reject it.
85+
{
86+
host: '8.8.8.8',
87+
cert: { subject: { CN: '8.8.8.8' }, subjectaltname: 'DNS:8.8.8.8' },
88+
error: 'IP: 8.8.8.8 is not in the cert\'s list: '
89+
},
90+
91+
// Likewise for "URI:" Subject Alternative Names.
92+
// See also https://github.com/nodejs/node/issues/8108.
93+
{
94+
host: '8.8.8.8',
95+
cert: { subject: { CN: '8.8.8.8' }, subjectaltname: 'URI:http://8.8.8.8/' },
96+
error: 'IP: 8.8.8.8 is not in the cert\'s list: '
97+
},
98+
99+
// An "IP Address:" Subject Alternative Name however is acceptable.
100+
{
101+
host: '8.8.8.8',
102+
cert: { subject: { CN: '8.8.8.8' }, subjectaltname: 'IP Address:8.8.8.8' }
103+
},
104+
105+
// But not when it's a CIDR.
106+
{
107+
host: '8.8.8.8',
108+
cert: {
109+
subject: { CN: '8.8.8.8' },
110+
subjectaltname: 'IP Address:8.8.8.0/24'
111+
},
112+
error: 'IP: 8.8.8.8 is not in the cert\'s list: '
113+
},
114+
73115
// Wildcards in CN
74116
{ host: 'b.a.com', cert: { subject: { CN: '*.a.com' } } },
75117
{

0 commit comments

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