Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-478

Error message is wrong in MongoReplicaSetConnection when SSL fails due to hostname mismatch

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.5
    • Component/s: None
    • Labels:
      None

      Description

      I found this while working on the SSL tests. I had my replica set configured with the local machine's hostname instead of the 'server' alias required for hostname matching:

      ======================================================================
      ERROR: test_cert_ssl_validation_optional (test.test_ssl.TestSSL)
      ----------------------------------------------------------------------
      Traceback (most recent call last):
        File "test/test_ssl.py", line 318, in test_cert_ssl_validation_optional
          db.test.drop()
        File "pymongo/collection.py", line 493, in drop
          self.__database.drop_collection(self.__name)
        File "pymongo/database.py", line 422, in drop_collection
          self.command("drop", unicode(name), allowable_errors=["ns not found"])
        File "pymongo/database.py", line 386, in command
          result = self["$cmd"].find_one(command, **extra_opts)
        File "pymongo/collection.py", line 598, in find_one
          for result in self.find(spec_or_id, *args, **kwargs).limit(-1):
        File "pymongo/cursor.py", line 814, in next
          if len(self.__data) or self._refresh():
        File "pymongo/cursor.py", line 763, in _refresh
          self.__uuid_subtype))
        File "pymongo/cursor.py", line 700, in __send_message
          **kwargs)
        File "pymongo/mongo_replica_set_client.py", line 1312, in _send_message_with_response
          raise AutoReconnect(msg, errors)
      AutoReconnect: No replica set primary available for query with ReadPreference PRIMARY

      That's really misleading. The fact that cert validation failed should bubble up to the user. Might be able to fix it by not catching CertificateError in pool.py.

        Attachments

          Activity

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: