code: def _validate_path(self):
          
  
          if self._path is not None:
              return
  
          exceptions = []
  
          if self._certificate.hash_algo in self._context.weak_hash_algos:
              raise InvalidCertificateError(pretty_message(
                  '''
                  The X.509 certificate provided has a signature using the weak
                  hash algorithm %s
                  ''',
                  self._certificate.hash_algo
              ))
  
          try:
              paths = self._context.certificate_registry.build_paths(self._certificate)
          except (PathBuildingError):
              if self._certificate.self_signed in set(['yes', 'maybe']):
                  raise InvalidCertificateError(pretty_message(
                      '''
                      The X.509 certificate provided is self-signed - "%s"
                      ''',
                      self._certificate.subject.human_friendly
                  ))
              raise
  
          for candidate_path in paths:
              try:
                  validate_path(self._context, candidate_path)
                  self._path = candidate_path
                  return
              except (ValidationError) as e:
                  exceptions.append(e)
  
          if len(exceptions) == 1:
              raise exceptions[0]
  
          non_signature_exception = None
          for exception in exceptions:
              if 'signature' not in str_cls(exception):
                  non_signature_exception = exception
  
          if non_signature_exception:
              raise non_signature_exception
  
          raise exceptions[0]
docs: Builds possible certificate paths and validates them until a valid one
          is found, or all fail.
  
          :raises:
              certvalidator.errors.PathValidationError - when an error occurs validating the path
              certvalidator.errors.RevokedError - when the certificate or another certificate in its path has been revoked