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

pymongo can't handle full fqdn string

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.5.1
    • Component/s: Auth

      When trying to open connection to Atlas cluster, pymongo failed with ServerSelectionTimeoutError due to wrong fqdn record. This is because we send the full fqdn with the dot at the end of the url.
      See full stack trace:
      ```File "/opt/fundbox/venvs/backend/fetching/local/lib/python2.7/site-packages/mongoengine/queryset/manager.py", line 37, in _get_
      queryset = queryset_class(owner, owner._get_collection())
      File "/opt/fundbox/venvs/backend/fetching/local/lib/python2.7/site-packages/mongoengine/document.py", line 176, in _get_collection
      db = cls._get_db()
      File "/opt/fundbox/venvs/backend/fetching/local/lib/python2.7/site-packages/mongoengine/document.py", line 169, in _get_db
      return get_db(cls._meta.get('db_alias', DEFAULT_CONNECTION_NAME))
      File "/opt/fundbox/venvs/backend/fetching/local/lib/python2.7/site-packages/mongoengine/connection.py", line 234, in get_db
      db.authenticate(conn_settings['username'], conn_settings['password'], **auth_kwargs)
      File "/opt/fundbox/venvs/backend/fetching/local/lib/python2.7/site-packages/pymongo/database.py", line 1075, in authenticate
      connect=True)
      File "/opt/fundbox/venvs/backend/fetching/local/lib/python2.7/site-packages/pymongo/mongo_client.py", line 542, in _cache_credentials
      writable_preferred_server_selector)
      File "/opt/fundbox/venvs/backend/fetching/local/lib/python2.7/site-packages/pymongo/topology.py", line 214, in select_server
      address))
      File "/opt/fundbox/venvs/backend/fetching/local/lib/python2.7/site-packages/pymongo/topology.py", line 189, in select_servers
      self._error_message(selector))
      ServerSelectionTimeoutError: hostname 'cluster0-shard-00-01-xxxxx.mongodb.net.' doesn't match either of '.mongodb.net', 'mongodb.net',hostname 'cluster0-shard-00-00-xxxxx.mongodb.net.' doesn't match either of '.mongodb.net', 'mongodb.net',hostname 'cluster0-shard-00-02-xxxxx.mongodb.net.' doesn't match either of '*.mongodb.net', 'mongodb.net'
      [9910:140625621952256] ```

      It is not an issue with Atlas as I can open a valide connection from my environment directly to such URI:
      :~$ openssl s_client -showcerts -connect cluster0-shard-00-02-xxxxx.mongodb.net.:27017
      CONNECTED(00000003)
      depth=2 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert Global Root CA
      verify return:1
      depth=1 C = US, O = DigiCert Inc, CN = DigiCert SHA2 Secure Server CA
      verify return:1
      depth=0 C = US, ST = New York, L = New York, O = "MongoDB, Inc.", CN = *.mongodb.net
      verify return:1

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            devops@fundbox.com Moshe Jacobs
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: