My postgres server should be forcing SSL connection however I would like to verify this setting directly from the Django app. Is there a way to inspect the database connection (perhaps through manage.py shell
and make sure the connection is SSL?
相关问题
- Django __str__ returned non-string (type NoneType)
- Django & Amazon SES SMTP. Cannot send email
- Django check user group permissions
- Mechanize getting “Errno::ECONNRESET: Connection r
- Django restrict pages to certain users
I believe I found one way, but I will wait before accepting in case people have critiques of this method:
create extension sslinfo;
to install the sslinfo extension. This may not be possible for some who don't have superuser access, however in my case where I configured server-side SSL enforcement, SU access is given.manage.py shell
:-
This executes raw SQL which should return [(True,)] if SSL is enabled.
Relevant documentation about sslinfo can be found here
I don't know how to configure that from your Django app, but maybe you could tell postgres to require SSL in the
sslmode
connection parameter?You can confirm that the connection is encrypted by looking for the cipher in the connection information after navigating to
python manage.py dbshell
otherwise, you will see no SSL information.