Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: expand tls-check-server-identity coverage
  • Loading branch information
diangogav committed Sep 24, 2025
commit fd96c235a11a1a33ab0d4d061f2510d12921fc3a
68 changes: 68 additions & 0 deletions test/parallel/test-tls-check-server-identity.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ const tests = [
cert: { subject: { CN: '.a.com' } },
error: 'Host: a.com. is not cert\'s CN: .a.com'
},
{
host: 'bad.x.example.com',
cert: { subject: { CN: 'bad..example.com' } },
error: 'Host: bad.x.example.com. is not cert\'s CN: bad..example.com'
},

// IP address in CN. Technically allowed but so rare that we reject
// it anyway. If we ever do start allowing them, we should take care
Expand Down Expand Up @@ -129,6 +134,16 @@ const tests = [
cert: { subject: { CN: 'b*b.a.com' } },
error: 'Host: b.a.com. is not cert\'s CN: b*b.a.com'
},
{
host: 'bxa.a.com',
cert: { subject: { CN: 'b**.a.com' } },
error: 'Host: bxa.a.com. is not cert\'s CN: b**.a.com'
},
{
host: 'xbcd.a.com',
cert: { subject: { CN: 'ab*cd.a.com' } },
error: 'Host: xbcd.a.com. is not cert\'s CN: ab*cd.a.com'
},

// Empty Cert
{
Expand Down Expand Up @@ -158,6 +173,11 @@ const tests = [
subject: { CN: ['foo.com', 'bar.com'] } // CN=foo.com; CN=bar.com;
}
},
{
host: 'a.com',
cert: { subject: { CN: [''] } },
error: 'Host: a.com. is not cert\'s CN: '
},

// DNS names and CN
{
Expand Down Expand Up @@ -212,6 +232,46 @@ const tests = [
},

// DNS names
{
host: 'a.com',
cert: {
subjectaltname: 'DNS:',
subject: {}
},
error: 'Host: a.com. is not in the cert\'s altnames: DNS:'
},
{
host: 'bad.x.example.com',
cert: {
subjectaltname: 'DNS:bad..example.com',
subject: {}
},
error: 'Host: bad.x.example.com. is not in the cert\'s altnames: DNS:bad..example.com'
},
{
host: 'x.example.com',
cert: {
subjectaltname: 'DNS:caf\u00E9.example.com', // "café.example.com"
subject: {}
},
error: 'Host: x.example.com. is not in the cert\'s altnames: DNS:caf\u00E9.example.com'
},
{
host: 'xbcd.a.com',
cert: {
subjectaltname: 'DNS:ab*cd.a.com',
subject: {}
},
error: 'Host: xbcd.a.com. is not in the cert\'s altnames: DNS:ab*cd.a.com'
},
{
host: 'x.example.com',
cert: {
subjectaltname: 'DNS:bad label.com',
subject: {}
},
error: 'Host: x.example.com. is not in the cert\'s altnames: DNS:bad label.com'
},
{
host: 'a.com', cert: {
subjectaltname: 'DNS:*.a.com',
Expand Down Expand Up @@ -261,6 +321,14 @@ const tests = [
subject: {}
}
},
{
host: 'bxa.a.com',
cert: {
subjectaltname: 'DNS:b**.a.com',
subject: {}
},
error: 'Host: bxa.a.com. is not in the cert\'s altnames: DNS:b**.a.com'
},
// URI names
{
host: 'a.b.a.com', cert: {
Expand Down
Loading