Re: [PATCH] Log details for client certificate failures

From: Jacob Champion <jchampion(at)timescale(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Log details for client certificate failures
Date: 2022-07-08 18:39:04
Message-ID: CAAWbhmgtVs0VciBwL4KbhQnLfTQKqwJjUUCxzA3SFECPn=ntTA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jul 7, 2022 at 2:50 AM Peter Eisentraut
<peter(dot)eisentraut(at)enterprisedb(dot)com> wrote:
> I looked into how you decode the serial number. I have found some code
> elsewhere that passed the result of X509_get_serialNumber() directly to
> ASN1_INTEGER_set(). But I guess a serial number of maximum length 20
> octets wouldn't fit into a 32-bit long. (There is
> ASN1_INTEGER_set_int64(), but that requires OpenSSL 1.1.0.) Does that
> match your understanding?

Yep. And the bit lengths of the serial numbers used in the test suite
are in the low 60s already. Many people will just randomize their
serial numbers, so I think BN_bn2dec() is the way to go.

> For the detail string, I think we could do something like:
>
> DETAIL: Failed certificate data (unverified): subject '%s', serial
> number %s, issuer '%s'

Done that way in v4.

I also added an optional 0002 that bubbles the error info up to the
final ereport(ERROR), using errdetail() and errhint(). I can squash it
into 0001 if you like it, or drop it if you don't. (This approach
could be adapted to the client, too.)

Thanks!
--Jacob

Attachment Content-Type Size
since-v3.diff.txt text/plain 4.5 KB
v4-0001-Log-details-for-client-certificate-failures.patch text/x-patch 14.1 KB
v4-0002-squash-Log-details-for-client-certificate-failure.patch text/x-patch 5.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ibrar Ahmed 2022-07-08 18:41:34 Re: Aggregate leads to superfluous projection from the scan
Previous Message Peter Geoghegan 2022-07-08 18:18:58 Re: Add last_vacuum_index_scans in pg_stat_all_tables