For ssl enabled MongoDB, we can connect MongoDB using naked pymongo apis by passing [ssl=True, ssl_cert_reqs=ssl.CERT_NONE] in MongoClient constructor and same support is missing in djongo
Python script
Under settings.py: following is not working as expected <<'SSL_CERT_REQS': ssl.CERT_NONE should work to bypass ssl certificate, but indeed it's not working>>
DATABASES = {
'default': {
'ENGINE' : 'djongo',
'HOST' : loader.load_property("db.host"),
'PORT' : loader.load_property("db.port"),
'NAME' : loader.load_property("db.name"),
'USER' : loader.load_property("db.user"),
'PASSWORD': loader.load_property("db.password"),
'SSL': True,
'SSL_CERT_REQS': ssl.CERT_NONE,
},
}
Traceback (most recent call last):
File "C:/ML/code/prod/python/dqi-ml/src/manage.py", line 21, in
main()
File "C:/ML/code/prod/python/dqi-ml/src/manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\core\management__init.py", line 381, in execute_from_command_line
utility.execute()
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\core\management__init.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, cmd_options)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, *options)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\core\management\base.py", line 83, in wrapped
res = handle_func(args, kwargs)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\core\management\commands\migrate.py", line 87, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\db\migrations\executor.py", line 18, in init__
self.loader = MigrationLoader(self.connection)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\db\migrations\loader.py", line 49, in init__
self.build_graph()
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\db\migrations\loader.py", line 212, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\db\migrations\recorder.py", line 73, in applied_migrations
if self.has_table():
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\db\migrations\recorder.py", line 56, in has_table
return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\db\backends\base\introspection.py", line 48, in table_names
return get_names(cursor)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\db\backends\base\introspection.py", line 43, in get_names
return sorted(ti.name for ti in self.get_table_list(cursor)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\djongo\introspection.py", line 46, in get_table_list
for c in cursor.db_conn.list_collection_names()
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\pymongo\database.py", line 856, in list_collection_names
for result in self.list_collections(session=session, **kwargs)]
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\pymongo\database.py", line 819, in list_collections
_cmd, read_pref, session)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\pymongo\mongo_client.py", line 1455, in _retryable_read
read_pref, session, address=address)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\pymongo\mongo_client.py", line 1254, in _select_server
server = topology.select_server(server_selector)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\pymongo\topology.py", line 231, in select_server
address))
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\pymongo\topology.py", line 189, in select_servers
selector, server_timeout, address)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\pymongo\topology.py", line 205, in _select_servers_loop
self._error_message(selector))
pymongo.errors.ServerSelectionTimeoutError: SSL handshake failed: 10.235.68.112:8635: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:847)
For ssl enabled MongoDB, we can connect MongoDB using naked pymongo apis by passing [ssl=True, ssl_cert_reqs=ssl.CERT_NONE] in MongoClient constructor and same support is missing in djongo
Python script
Under settings.py: following is not working as expected <<'SSL_CERT_REQS': ssl.CERT_NONE should work to bypass ssl certificate, but indeed it's not working>> DATABASES = { 'default': { 'ENGINE' : 'djongo', 'HOST' : loader.load_property("db.host"), 'PORT' : loader.load_property("db.port"), 'NAME' : loader.load_property("db.name"), 'USER' : loader.load_property("db.user"), 'PASSWORD': loader.load_property("db.password"), 'SSL': True, 'SSL_CERT_REQS': ssl.CERT_NONE, }, }
Traceback
Traceback (most recent call last): File "C:/ML/code/prod/python/dqi-ml/src/manage.py", line 21, in
main()
File "C:/ML/code/prod/python/dqi-ml/src/manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\core\management__init.py", line 381, in execute_from_command_line
utility.execute()
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\core\management__init.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, cmd_options)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, *options)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\core\management\base.py", line 83, in wrapped
res = handle_func(args, kwargs)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\core\management\commands\migrate.py", line 87, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\db\migrations\executor.py", line 18, in init__
self.loader = MigrationLoader(self.connection)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\db\migrations\loader.py", line 49, in init__
self.build_graph()
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\db\migrations\loader.py", line 212, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\db\migrations\recorder.py", line 73, in applied_migrations
if self.has_table():
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\db\migrations\recorder.py", line 56, in has_table
return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\db\backends\base\introspection.py", line 48, in table_names
return get_names(cursor)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\django\db\backends\base\introspection.py", line 43, in get_names
return sorted(ti.name for ti in self.get_table_list(cursor)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\djongo\introspection.py", line 46, in get_table_list
for c in cursor.db_conn.list_collection_names()
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\pymongo\database.py", line 856, in list_collection_names
for result in self.list_collections(session=session, **kwargs)]
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\pymongo\database.py", line 819, in list_collections
_cmd, read_pref, session)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\pymongo\mongo_client.py", line 1455, in _retryable_read
read_pref, session, address=address)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\pymongo\mongo_client.py", line 1254, in _select_server
server = topology.select_server(server_selector)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\pymongo\topology.py", line 231, in select_server
address))
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\pymongo\topology.py", line 189, in select_servers
selector, server_timeout, address)
File "C:\ML\installed_tools\anaconda3\envs\free-python\lib\site-packages\pymongo\topology.py", line 205, in _select_servers_loop
self._error_message(selector))
pymongo.errors.ServerSelectionTimeoutError: SSL handshake failed: 10.235.68.112:8635: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:847)
Process finished with exit code 1