@@ -169,14 +169,14 @@ function check(hostParts, pattern, wildcards) {
169169  return  true ; 
170170} 
171171
172- exports . checkServerIdentity  =  function  checkServerIdentity ( host ,  cert )  { 
172+ exports . checkServerIdentity  =  function  checkServerIdentity ( hostname ,  cert )  { 
173173  const  subject  =  cert . subject ; 
174174  const  altNames  =  cert . subjectaltname ; 
175175  const  dnsNames  =  [ ] ; 
176176  const  uriNames  =  [ ] ; 
177177  const  ips  =  [ ] ; 
178178
179-   host  =  ''  +  host ; 
179+   hostname  =  ''  +  hostname ; 
180180
181181  if  ( altNames )  { 
182182    for  ( const  name  of  altNames . split ( ', ' ) )  { 
@@ -194,14 +194,14 @@ exports.checkServerIdentity = function checkServerIdentity(host, cert) {
194194  let  valid  =  false ; 
195195  let  reason  =  'Unknown reason' ; 
196196
197-   if  ( net . isIP ( host ) )  { 
198-     valid  =  ips . includes ( canonicalizeIP ( host ) ) ; 
197+   if  ( net . isIP ( hostname ) )  { 
198+     valid  =  ips . includes ( canonicalizeIP ( hostname ) ) ; 
199199    if  ( ! valid ) 
200-       reason  =  `IP: ${ host } ${ ips . join ( ', ' ) }  ; 
200+       reason  =  `IP: ${ hostname } ${ ips . join ( ', ' ) }  ; 
201201    // TODO(bnoordhuis) Also check URI SANs that are IP addresses. 
202202  }  else  if  ( subject )  { 
203-     host  =  unfqdn ( host ) ;   // Remove trailing dot for error messages. 
204-     const  hostParts  =  splitHost ( host ) ; 
203+     hostname  =  unfqdn ( hostname ) ;   // Remove trailing dot for error messages. 
204+     const  hostParts  =  splitHost ( hostname ) ; 
205205    const  wildcard  =  ( pattern )  =>  check ( hostParts ,  pattern ,  true ) ; 
206206    const  noWildcard  =  ( pattern )  =>  check ( hostParts ,  pattern ,  false ) ; 
207207
@@ -215,11 +215,12 @@ exports.checkServerIdentity = function checkServerIdentity(host, cert) {
215215        valid  =  wildcard ( cn ) ; 
216216
217217      if  ( ! valid ) 
218-         reason  =  `Host: ${ host } ${ cn }  ; 
218+         reason  =  `Host: ${ hostname } ${ cn }  ; 
219219    }  else  { 
220220      valid  =  dnsNames . some ( wildcard )  ||  uriNames . some ( noWildcard ) ; 
221221      if  ( ! valid ) 
222-         reason  =  `Host: ${ host } ${ altNames }  ; 
222+         reason  = 
223+           `Host: ${ hostname } ${ altNames }  ; 
223224    } 
224225  }  else  { 
225226    reason  =  'Cert is empty' ; 
@@ -228,7 +229,7 @@ exports.checkServerIdentity = function checkServerIdentity(host, cert) {
228229  if  ( ! valid )  { 
229230    const  err  =  new  ERR_TLS_CERT_ALTNAME_INVALID ( reason ) ; 
230231    err . reason  =  reason ; 
231-     err . host  =  host ; 
232+     err . host  =  hostname ; 
232233    err . cert  =  cert ; 
233234    return  err ; 
234235  } 
0 commit comments