Add post-quantum cryptography (PQC) support to SSLConfig - #53
Draft
junaruga wants to merge 1 commit into
Draft
Conversation
DRb::DRbSSLSocket::SSLConfig already works
with pre-generated ML-DSA cert/key by
:SSLCertificate and :SSLPrivateKey config options.
This commit adds the following features in PQC use cases to #setup_certificate
and #setup_ssl_context.
* Add :SSLCertificates config option accepting an Array of
[certificate, private_key] pairs for dual/multiple certificate
support via OpenSSL::SSL::SSLContext#add_certificate
changing from OpenSSL::SSL::SSLContext#cert and #key.
Because an SSL server that accepts clients with either ML-DSA-NN
or RSA certificates is useful in the use case of PQC migration from RSA
(non-PQC) to ML-DSA (PQC).
:SSLCertificate and :SSLPrivateKey are available for backward compatibility.
But use OpenSSL::SSL::SSLContext#add_certificate internally.
This is a behavior change.
* Add :SSLPrivateKeyAlgorithms option accepting an Array of key
algorithms (RSA, ML-DSA-44, ML-DSA-65, ML-DSA-87) for
multi-certificate generation, defaulting to ["RSA"] for backward
compatibility.
* Add :SSLGroups option to control key exchange group such as ML-KEM in PQC.
* Add :SSLSignatureAlgorithms, :SSLClientSignatureAlgorithms to control
signature algorithms such as ML-DSA-NN in PQC, and RSA in non-PQC.
* Add tool/create_certs.sh to generate test/drb/fixtures/*.{crt,key}
to test with pre-generated certs/keys and add DRbTests::Fixtures module
to read the certs/keys.
* Add test/drb/test_ssl.rb to test lib/drb/ssl.rb as an unit test level.
This approach aligns with test/drb/test_acl.rb to test lib/drb/acl.rb
as an unit test level.
* Add TestDRbSSLPQC, TestDRbSSLPQCMultiCertMLDSA65, TestDRbSSLPQCMultiCertRSA
in test/drb/test_drbssl.rb.
TestDRbSSLPQC is to test single PQC ML-KEM/ML-DSA server via
test/drb/ut_drb_drbssl_pqc.rb. The testing class is inspired by
TestDRbSSLCore.
TestDRbSSLPQCMultiCertMLDSA65 and TestDRbSSLPQCMultiCertRSA are to test
ML-DSA-65 (PQC) and RSA (non-PQC) dual (multiple) certificate server
with client certificate via test/drb/ut_drb_drbssl_pqc_multi_cert.rb.
The test is designed for a high-security use case with :SSLVerifyMode
OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT.
Assisted-by: Claude:claude-opus-4-6[1m]
Member
Author
|
I see the following CI failure. Let me fix it. https://github.com/ruby/drb/actions/runs/30444292244/job/90550763624?pr=53 |
junaruga
marked this pull request as draft
July 29, 2026 10:40
junaruga
commented
Jul 29, 2026
| cert.not_before = Time.now | ||
| cert.not_after = Time.now + (365*24*60*60) | ||
| cert.public_key = rsa.public_key | ||
| cert.public_key = OpenSSL::PKey.read(pkey.public_to_der) |
Member
Author
There was a problem hiding this comment.
The reason for this change is because OpenSSL::PKey::PKey class for ML-DSA-NN doesn't have #public_key unlike OpenSSL::PKey::RSA. So, I picked up the following OpenSSL::PKey::RSA#public_key internal logic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is related to #52.
Proof of concept
I prepared proof-of-concept scripts for this PR.
The document (
drb/README.md) is here. A list of the sections in thedrb/README.mdis below. The sections without "(development)" test with the current master branch. These work. The sections with "(development)" test with this PR.The script is here. The CI result is here.
Commit message
DRb::DRbSSLSocket::SSLConfig already works
with pre-generated ML-DSA cert/key by
:SSLCertificate and :SSLPrivateKey config options.
This commit adds the following features in PQC use cases to #setup_certificate and #setup_ssl_context.
Assisted-by: Claude:claude-opus-4-6[1m]
Notes
CI cases supporting PQC
PQC (ML-KEM/ML-DSA) works in OpenSSL >= 3.5. OpenSSL 3.5 added the feature. And works in Ruby OpenSSL >= 4.0. Ruby OpenSSL 4.0.0 added some functions in PQC use cases, and fixed a bug.
The
.github/workflows/test.ymluses runner ubuntu-latest, macos-latest, windows-latest.According to https://github.com/actions/runner-images, ubuntu-latest is ubuntu-24.04, macos-latest is macOS-26-arm64, windows-latest is windows-2025-vs2026.
The ubuntu-24.04 uses OpenSSL 3.0.13 which doesn't support PQC. The windows-2025-vs2026 uses OpenSSL 3.6.3 which supports PQC. The macos-26 uses OpenSSL 3.6.2 which supports PQC. The new PQC tests should be executed on the macos-latest and windows-latest CI cases.
test/drb/test_ssl.rb testing lib/drb/ssl.rb as an unit test level
I checked all the existing
test/drb/test_*.rbfiles.So, I created test/drb/test_ssl.rb to test
DRb::DRbSSLSocket::SSLConfigin lib/drb/ssl.rb as an unit test level.tool/create_certs.sh design decisions
The tool/create_certs.sh is inspired by ruby/rubygems#9678. The directory test/drb/fixtures to manage SSL key/cert files is inspired by ruby/openssl managing SSL keys in test/openssl/fixtures/pkey directory. ruby/openssl manages only key files, not certificate files. ruby/openssl is generating testing certificates from the keys in tests.
Testing in RubyCI servers
I plan to test this PR with RHEL 9 server (OpenSSL version is >= 3.5, but OpenSSL config disables PQC by default), which is the case of
support_pqc_handshake?isfalse,and OpenBSD server as I saw the following logic inDRbSSLService, test/drb/test_drbssl.rb.