On 11/08/2026 16:24, Peter Eisentraut wrote:
I was curious about the hardcoded FILE_DH2048 in src/include/libpq/
libpq-be.h -- how did it get there, do we ever need to update it, how do
we know, etc. -- and it seems that there is a more modern approach that
allows us to get rid of it.
Previously, if ssl_dh_params_file was not set, the compiled-in default
parameters in FILE_DH2048 were used. Instead, we can call
SSL_CTX_set_dh_auto() and have OpenSSL choose appropriate, well-known,
and appropriately sized parameters. In particular, the size of the
parameters is chosen consistent with the size of the key and
certificate, and so it can automatically grow with new standards and
best practices. This facility was not available at the time FILE_DH2048
was added, but it is now available in all relevant OpenSSL and LibreSSL
versions.
I think this new behavior is preferable (also consistent with
recommendations in the OpenSSL documentation), so I have tweaked the
documentation a bit in that direction.
There was also some not-very-modern text about this in README.SSL,
which I have deleted.
Interesting, I didn't know about SSL_CTX_set_dh_auto(). Makes much more
sense than having hardcoded parameters in the application (PostgreSQL in
this case).
Note that if you use a very small certificate/key size, then this
could mean that the size of the chosen DH parameters could also end up
smaller than the previous hard-coded default. But that could only
happen if you disregarded all current security best practices anyway.
Yeah, seems fine.
Note a small behavior change: Previously, if loading the DH file
failed during a server reload, the system would then fall back to
using the built-in parameters, instead of failing the reload and
keeping the old SSL context, which is what it would do if some other
aspect of reinitializing SSL would fail. I think this is actually a
bug. I have fixed this here as part of reflowing the relevant function.
Anyway, this is all very complicated and obscure. Reviews are welcome.
LGTM. I wonder if we should just remove the ssl_dh_params_file option.
If I understand correctly, there's no reason for anyone to use it.
- Heikki