From: | Daniel Gustafsson <daniel(at)yesql(dot)se> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Jacob Champion <jchampion(at)timescale(dot)com>, "Gregory Stark (as CFM)" <stark(dot)cfm(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Magnus Hagander <magnus(at)hagander(dot)net>, Michael Paquier <michael(at)paquier(dot)xyz>, thomas(at)habets(dot)se, Bruce Momjian <bruce(at)momjian(dot)us>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Jelte Fennema <postgres(at)jeltef(dot)nl> |
Subject: | Re: [PATCH] Add `verify-system` sslmode to use system CA pool for server cert |
Date: | 2023-04-14 08:04:27 |
Message-ID: | 7D3F923B-7DD0-477B-84B3-9C0D56A4E573@yesql.se |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> On 14 Apr 2023, at 01:27, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Daniel Gustafsson <daniel(at)yesql(dot)se> writes:
>> Good points, it should of course be SOCK_ERRNO. The attached saves off errno
>> and reinstates it to avoid clobbering. Will test it on Windows in the morning
>> as well.
>
> I think instead of this:
>
> + SOCK_ERRNO_SET(save_errno);
>
> you could just do this:
>
> libpq_append_conn_error(conn, "SSL SYSCALL error: %s",
> - SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
> + SOCK_STRERROR(save_errno, sebuf, sizeof(sebuf)));
>
> Although ... we're already assuming that SSL_get_error and ERR_get_error
> don't clobber errno. Maybe SSL_get_verify_result doesn't either.
> Or we could make it look like this:
>
> + SOCK_ERRNO_SET(0);
> ERR_clear_error();
> r = SSL_connect(conn->ssl);
> if (r <= 0)
> + int save_errno = SOCK_ERRNO;
> int err = SSL_get_error(conn->ssl, r);
> unsigned long ecode;
>
> ...
>
> - SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
> + SOCK_STRERROR(save_errno, sebuf, sizeof(sebuf)));
>
> to remove all doubt.
I mainly put save_errno back into SOCK_ERRNO for greppability, I don't have any
strong opinions either way so I went with the latter suggestion. Attached v3
does the above change and passes the tests both with a broken and working
system CA pool. Unless objections from those with failing local envs I propose
this is pushed to close the open item.
--
Daniel Gustafsson
Attachment | Content-Type | Size |
---|---|---|
libpq_system_ca_fix_v3.diff | application/octet-stream | 1.5 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Daniel Gustafsson | 2023-04-14 08:12:51 | Re: User functions for building SCRAM secrets |
Previous Message | Kyotaro Horiguchi | 2023-04-14 08:01:48 | Re: Fix documentation for max_wal_size and min_wal_size |