Skip to content

ssl: use SSL_CTX_set_dh_auto() by default #924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

rhenium
Copy link
Member

@rhenium rhenium commented Aug 1, 2025

Enable automatic DH parameters for TLS 1.2 or earlier when neither SSLSocket#tmp_dh nor SSLSocket#tmp_dh_callback is set. This is supported since OpenSSL 1.1.0.

This allows us to remove the default tmp_dh_callback proc defined in lib/openssl/ssl.rb, which uses hard-coded parameters and is not Ractor-shareable.

Also, a few cleanups in related code:


provider: load "default" provider in test_openssl_legacy_provider

Explicitly load both the "default" and "legacy" providers in the test case.

The "legacy" provider is intended to be used with the "default" provider. The "default" provider is typically loaded automatically, but that only happens when no other provider has been loaded yet.


ssl: fix extconf.rb check for SSL_CTX_set0_tmp_dh_pkey()

Check for the function we actually use. Both SSL_set0_tmp_dh_pkey() and SSL_CTX_set0_tmp_dh_pkey() were added in OpenSSL 3.0.


ssl: refactor tmp_dh_callback handling

tmp_dh_callback no longer has a default value. It also no longer has to share code with tmp_ecdh_callback, which was removed in v3.0.0.

rhenium added 4 commits August 1, 2025 21:02
Explicitly load both the "default" and "legacy" providers in the test
case.

The "legacy" provider is intended to be used with the "default"
provider. The "default" provider is typically loaded automatically, but
that only happens when no other provider has been loaded yet.
Check for the function we actually use. Both SSL_set0_tmp_dh_pkey() and
SSL_CTX_set0_tmp_dh_pkey() were added in OpenSSL 3.0.
Enable automatic DH parameters for TLS 1.2 or earlier when neither
SSLSocket#tmp_dh nor SSLSocket#tmp_dh_callback is set. This is supported
since OpenSSL 1.1.0.

This allows us to remove the default tmp_dh_callback proc defined in
lib/openssl/ssl.rb, which uses hard-coded parameters and is not
Ractor-shareable.
tmp_dh_callback no longer has a default value. It also no longer has to
share code with tmp_ecdh_callback, which was removed in v3.0.0.
@rhenium
Copy link
Member Author

rhenium commented Aug 1, 2025

I don't think the failure with openssl-master with the fips provider is relevant, but I haven't been able to reproduce it locally.

@junaruga
Copy link
Member

junaruga commented Aug 1, 2025

I don't think the failure with openssl-master with the fips provider is relevant, but I haven't been able to reproduce it locally.

I executed the current latest master branch dfbbac6 with the latest OpenSSL master branch openssl/openssl@b20da23. I can see the failure below.

https://github.com/junaruga/ruby-openssl/actions/runs/16680199093/job/47216748820

@junaruga
Copy link
Member

junaruga commented Aug 1, 2025

I opened the issue ticket #926 for the FIPS test failures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants