title: pymongo [SSL: CERTIFICATE_VERIFY_FAILED]: certificate has expired on Mongo Atlas
body: <p>I am using MongoDB(Mongo Atlas) in my Django app. All was working fine till yesterday. But today, when I ran the server, it is showing me the following error on console</p>
  <pre><code>Exception in thread django-main-thread:
  Traceback (most recent call last):
    File &quot;c:\users\admin\appdata\local\programs\python\python39\lib\threading.py&quot;, line 973, in _bootstrap_inner
      self.run()
    File &quot;c:\users\admin\appdata\local\programs\python\python39\lib\threading.py&quot;, line 910, in run
      self._target(*self._args, **self._kwargs)
    File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\utils\autoreload.py&quot;, line 64, in wrapper
      fn(*args, **kwargs)
    File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\core\management\commands\runserver.py&quot;, line 121, in inner_run
      self.check_migrations()
    File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\core\management\base.py&quot;, line 486, in check_migrations
      executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
    File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\executor.py&quot;, line 18, in __init__
      self.loader = MigrationLoader(self.connection)
    File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\loader.py&quot;, line 53, in __init__
      self.build_graph()
    File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\loader.py&quot;, line 220, in build_graph
      self.applied_migrations = recorder.applied_migrations()
    File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\recorder.py&quot;, line 77, in applied_migrations
      if self.has_table():
    File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\recorder.py&quot;, line 56, in has_table
      tables = self.connection.introspection.table_names(cursor)
    File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\backends\base\introspection.py&quot;, line 52, in table_names
      return get_names(cursor)
    File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\backends\base\introspection.py&quot;, line 47, in get_names
      return sorted(ti.name for ti in self.get_table_list(cursor)
    File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\djongo\introspection.py&quot;, line 47, in get_table_list
      for c in cursor.db_conn.list_collection_names()
    File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\database.py&quot;, line 880, in list_collection_names
      for result in self.list_collections(session=session, **kwargs)]
    File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\database.py&quot;, line 842, in list_collections
      return self.__client._retryable_read(
    File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\mongo_client.py&quot;, line 1514, in _retryable_read
      server = self._select_server(
    File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\mongo_client.py&quot;, line 1346, in _select_server
      server = topology.select_server(server_selector)
    File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\topology.py&quot;, line 244, in select_server
      return random.choice(self.select_servers(selector,
    File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\topology.py&quot;, line 202, in select_servers
      server_descriptions = self._select_servers_loop(
    File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\topology.py&quot;, line 218, in _select_servers_loop
      raise ServerSelectionTimeoutError(
  pymongo.errors.ServerSelectionTimeoutError: cluster0-shard-00-02.mny7y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129),cluster0-shard-00-01.mny7y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129),cluster0-shard-00-00.mny7y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129), Timeout: 30s, Topology Description: &lt;TopologyDescription id: 6155f0c9148b07ff5851a1b3, topology_type: ReplicaSetNoPrimary, servers: [&lt;ServerDescription ('cluster0-shard-00-00.mny7y.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('cluster0-shard-00-00.mny7y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)')&gt;, &lt;ServerDescription ('cluster0-shard-00-01.mny7y.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('cluster0-shard-00-01.mny7y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)')&gt;, &lt;ServerDescription ('cluster0-shard-00-02.mny7y.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('cluster0-shard-00-02.mny7y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)')&gt;]&gt;
  </code></pre>
  <p>I am using <strong>djongo</strong> as the database engine</p>
  <pre><code>DATABASES = {
      'default': {
              'ENGINE': 'djongo',
              'NAME': 'DbName',
              'ENFORCE_SCHEMA': False,
              'CLIENT': {
                  'host': 'mongodb+srv://username:password@cluster0.mny7y.mongodb.net/DbName?retryWrites=true&amp;w=majority'
              }  
      }
  }
  </code></pre>
  <p>And following dependencies are being used in the app</p>
  <pre><code>dj-database-url==0.5.0
  Django==3.2.5
  djangorestframework==3.12.4
  django-cors-headers==3.7.0
  gunicorn==20.1.0
  psycopg2==2.9.1
  pytz==2021.1
  whitenoise==5.3.0
  djongo==1.3.6
  dnspython==2.1.0
  </code></pre>
  <p>What should be done in order to resolve this error?</p>