summaryrefslogtreecommitdiff
path: root/django/db/backends/postgresql/client.py
diff options
context:
space:
mode:
authorOleh Mykytiuk <oleh_mykytiuk@epam.com>2019-04-16 12:40:22 +0300
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-04-18 08:10:31 +0200
commit177fa08339c4908afbefbda5dceabe72641ec915 (patch)
treef4fee967494e307a6326e647605004219358b49b /django/db/backends/postgresql/client.py
parentd87bd29c4f8dfcdf3f4a4eb8340e6770a2416fe3 (diff)
downloaddjango-177fa08339c4908afbefbda5dceabe72641ec915.tar.gz
Fixed #30370 -- Added dbshell support for client TLS certificates on PostgreSQL.
Diffstat (limited to 'django/db/backends/postgresql/client.py')
-rw-r--r--django/db/backends/postgresql/client.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/django/db/backends/postgresql/client.py b/django/db/backends/postgresql/client.py
index cf4df76882..0efe0d47f0 100644
--- a/django/db/backends/postgresql/client.py
+++ b/django/db/backends/postgresql/client.py
@@ -17,6 +17,10 @@ class DatabaseClient(BaseDatabaseClient):
dbname = conn_params.get('database', '')
user = conn_params.get('user', '')
passwd = conn_params.get('password', '')
+ sslmode = conn_params.get('sslmode', '')
+ sslrootcert = conn_params.get('sslrootcert', '')
+ sslcert = conn_params.get('sslcert', '')
+ sslkey = conn_params.get('sslkey', '')
if user:
args += ['-U', user]
@@ -30,6 +34,14 @@ class DatabaseClient(BaseDatabaseClient):
subprocess_env = os.environ.copy()
if passwd:
subprocess_env['PGPASSWORD'] = str(passwd)
+ if sslmode:
+ subprocess_env['PGSSLMODE'] = str(sslmode)
+ if sslrootcert:
+ subprocess_env['PGSSLROOTCERT'] = str(sslrootcert)
+ if sslcert:
+ subprocess_env['PGSSLCERT'] = str(sslcert)
+ if sslkey:
+ subprocess_env['PGSSLKEY'] = str(sslkey)
try:
# Allow SIGINT to pass to psql to abort queries.
signal.signal(signal.SIGINT, signal.SIG_IGN)