Skip to content

Commit e77cfa5

Browse files
committed
Fix pg_stat_ssl.clientdn
Return null if there is no client certificate. This is how it has always been documented, but in reality it returned an empty string. Reviewed-by: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp> Discussion: https://www.postgresql.org/message-id/flat/398754d8-6bb5-c5cf-e7b8-22e5f0983caf@2ndquadrant.com/
1 parent 1805954 commit e77cfa5

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/backend/utils/adt/pgstatfuncs.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,10 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
652652
values[20] = CStringGetTextDatum(beentry->st_sslstatus->ssl_cipher);
653653
values[21] = Int32GetDatum(beentry->st_sslstatus->ssl_bits);
654654
values[22] = BoolGetDatum(beentry->st_sslstatus->ssl_compression);
655-
values[23] = CStringGetTextDatum(beentry->st_sslstatus->ssl_clientdn);
655+
if (beentry->st_sslstatus->ssl_clientdn[0])
656+
values[23] = CStringGetTextDatum(beentry->st_sslstatus->ssl_clientdn);
657+
else
658+
nulls[23] = true;
656659
}
657660
else
658661
{

src/test/ssl/t/001_ssltests.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@
316316
'-c', "SELECT * FROM pg_stat_ssl WHERE pid = pg_backend_pid()"
317317
],
318318
qr{^pid,ssl,version,cipher,bits,compression,clientdn\n
319-
^\d+,t,TLSv[\d.]+,[\w-]+,\d+,f,$}mx,
319+
^\d+,t,TLSv[\d.]+,[\w-]+,\d+,f,_null_$}mx,
320320
'pg_stat_ssl view without client certificate');
321321

322322
### Server-side tests.

0 commit comments

Comments
 (0)