使用dbshel​​l命令在Django和PostgreSQL中启用SSL?

时间:2018-11-20 17:28:03

标签: python ssl postgresql-9.6 django-2.1

我正在尝试运行其他SO question中所述的python manage.py dbshell命令。但我得到了:

      FATAL:  pg_hba.conf rejects connection for host "my_ip", user "django", database "my_db", SSL off
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/django/projects/DJANGO_DB/lib/python3.5/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/home/django/projects/DJANGO_DB/lib/python3.5/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/django/projects/DJANGO_DB/lib/python3.5/site-packages/django/core/management/base.py", line 316, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/django/projects/DJANGO_DB/lib/python3.5/site-packages/django/core/management/base.py", line 353, in execute
    output = self.handle(*args, **options)
  File "/home/django/projects/DJANGO_DB/lib/python3.5/site-packages/django/core/management/commands/dbshell.py", line 22, in handle
    connection.client.runshell()
  File "/home/django/projects/DJANGO_DB/lib/python3.5/site-packages/django/db/backends/postgresql/client.py", line 71, in runshell
    DatabaseClient.runshell_db(self.connection.get_connection_params())
  File "/home/user/Projects/DJANGO_DB/lib/python3.5/site-packages/django/db/backends/postgresql/client.py", line 61, in runshell_db
    subprocess.check_call(args)
  File "/usr/lib/python3.5/subprocess.py", line 581, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['psql', '-U', 'django', '-h', 'mydomain.com', '-p', '5432', 'my_db']' returned non-zero exit status 2

通过gunicorn和常用的python manage.py runserver命令连接到数据库非常有效。

但是,我试图验证SSL是否在开发服务器和GC实例之间正常工作(应该启用它并将我的IP地址和复制的密钥列入白名单),但是无法使用外壳非常烦人。任何帮助都太棒了!

0 个答案:

没有答案