Skip to content

[fix] support AES128, AES256 and CHACHA20 cipher aliases - #390

Merged
kares merged 3 commits into
jruby:masterfrom
sampokuokkanen:cipher-string-and
Oct 22, 2026
Merged

kares merged 3 commits into
jruby:masterfrom
sampokuokkanen:cipher-string-and

Conversation

@sampokuokkanen

Copy link
Copy Markdown
Contributor

These were not registered, so ciphers = 'AES128' raised "no cipher match", and in a "+" rule the unknown name was skipped: EECDH+CHACHA20 and EECDH+AES128 both selected every EECDH suite.

AES128 and AES256 match on key size. An unknown name in a "+" rule now drops the whole rule, as libssl's ssl_cipher_process_rulestr does.

Found while checking falcon's TLS tests. They failed on 0.19.3 because of the missing EECDH (fixed in #387). The localhost gem's SERVER_CIPHERS (EECDH+CHACHA20:EECDH+AES128:...) then still selected the wrong suites on master. Falcon's tests pass either way, since they don't check which suites are chosen.

These were not registered, so ciphers = 'AES128' raised "no cipher
match", and in a "+" rule the unknown name was skipped:
EECDH+CHACHA20 and EECDH+AES128 both selected every EECDH suite.

AES128 and AES256 match on key size. An unknown name in a "+" rule now
drops the whole rule, as libssl's ssl_cipher_process_rulestr does.
Comment thread src/main/java/org/jruby/ext/openssl/CipherStrings.java Outdated
Comment thread src/main/java/org/jruby/ext/openssl/CipherStrings.java
@sampokuokkanen
sampokuokkanen requested a review from kares October 22, 2026 09:13
@kares kares added this to the 0.19.4 milestone Oct 22, 2026
else {
matching.retainAll( matchingPattern(pattern, all, false, setSuite) );
}
if ( pattern == null ) return null; // unknown name drops the rule (libssl ssl_cipher_process_rulestr)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will reject valid combined rules containing an individual cipher name

OpenSSL accepts AES128+ECDHE-RSA-AES128-GCM-SHA256 and select that suite
PR raises OpenSSL::SSL::SSLError: no cipher match

we should resolve offered cipher names, including RFC names, before applying the unknown rule...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, should be fixed now. Seems like it was broken before this PR too, master raises no cipher match here.

A + rule only looked up aliases, so cipher names got skipped (EECDH+ECDHE-RSA-AES128-GCM-SHA256 gave all of EECDH). An RFC name as a plain string didn't work either, only inside an Array.

Now each part can be an alias, an OpenSSL name or an RFC name, and the rule is what they have in common, like CRuby:

ctx.ciphers = "AES128+ECDHE-RSA-AES128-GCM-SHA256"           # ECDHE-RSA-AES128-GCM-SHA256
ctx.ciphers = "AES128+TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" # ECDHE-RSA-AES128-GCM-SHA256
ctx.ciphers = "AES256+ECDHE-RSA-AES128-GCM-SHA256"           # no cipher match
ctx.ciphers = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"        # works now

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, sorry - seems like it was broken indeed.
didn't realize that, just recalled we support the raw names and that they likely won't cut if with the changes.

@kares
kares merged commit a9ce05e into jruby:master Oct 22, 2026
74 checks passed
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