Django使用cert认证连接到Postgresql [英] Django connection to Postgresql using cert authentication

查看:142
本文介绍了Django使用cert认证连接到Postgresql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Django 1.9中,为了使用cert认证连接到postgresql数据库,在settings.py中需要做哪些更改?

In Django 1.9, what changes do I have to make in settings.py in order to connect to a postgresql database using cert authentication?

推荐答案

据我所知,django使用psycopg2,后者又使用libpq。这意味着您不需要对settings.py进行任何更改。

To my knowledge, django uses psycopg2, which in turn uses libpq. This means you shouldn't need to make any changes to settings.py.

您必须使用配置服务器,以便它请求并知道如何验证证书,而在客户端,您需要将crt和键入正确的目录(例如〜/ .postgresql),以便libpq知道如何找到它们。一旦这样做正确,它应该适用于任何Django特定代码的更改。

You have to configure the server properly so it asks for and knows how to validate the certificate, and on the client side you need to put the crt and the key in the correct directory (e.g. ~/.postgresql) so that libpq knows how to find them. Once that is done properly, it should just work with no changes to any Django-specific code.

这篇关于Django使用cert认证连接到Postgresql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆