lib/agent/socket_util.js
function(certs, index)
  {
    var cert = certs[index];
    validateCert(cert, function(err, data)
    {
      completed++;
      errors[index] = err;

      // if we have an ocsp response, cache it
      if (data)
      {
        getOcspResponseCache().set(cert, data);
      }

      // if this is the last request to complete
      if (completed === certs.length)
      {
        // if we saw one or more errors, invoke the callback with the first
        // error we saw; otherwise invoke the callback without any error
        for (var errorIndex = 0, length = errors.length;
             errorIndex < length; errorIndex++)
        {
          var error = errors[errorIndex];
          if (error)
          {
            break;
          }
        }
        cb(error);
      }
    });
  }
function(certs, index)
  {
    var cert = certs[index];
    validateCert(cert, function(err, data)
    {
      completed++;
      errors[index] = err;

      // if we have an ocsp response, cache it
      if (data)
      {
        getOcspResponseCache().set(cert, data);
      }

      // if this is the last request to complete
      if (completed === certs.length)
      {
        // if we saw one or more errors, invoke the callback with the first
        // error we saw; otherwise invoke the callback without any error
        for (var errorIndex = 0, length = errors.length;
             errorIndex < length; errorIndex++)
        {
          var error = errors[errorIndex];
          if (error)
          {
            break;
          }
        }
        cb(error);
      }
    });
  }
function ( certs , index ) { var cert = certs [ index ] ; validateCert ( cert , function ( err , data ) { completed ++ ; errors [ index ] = err ; // if we have an ocsp response, cache it if ( data ) { getOcspResponseCache ( ) . set ( cert , data ) ; } // if this is the last request to complete if ( completed === certs . length ) { // if we saw one or more errors, invoke the callback with the first // error we saw; otherwise invoke the callback without any error for ( var errorIndex = 0 , length = errors . length ; errorIndex < length ; errorIndex ++ ) { var error = errors [ errorIndex ] ; if ( error ) { break ; } } cb ( error ) ; } } ) ; }
Called for every certificate as we traverse the certificate chain and
validate each one.

@param certs
@param index
Called for every certificate as we traverse the certificate chain and validate each one .