Skip to content
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

TLS1.2 enforcement pains & JRuby, particularly hurting for TLS_RSA_WITH_AES_256_CBC_SHA256 #168

Closed
bbozo opened this issue Jun 27, 2018 · 3 comments

Comments

@bbozo
Copy link

bbozo commented Jun 27, 2018

Continuing on jruby/jruby#2194, as the title says, more and more services force TLS v1.2 and the lack of ciphers on JRuby is hurting very, very badly - a particular critical service jumped out yesterday due to TLS v1.2 enforcement, and I've got no options to put it back up at the moment under JRuby (MRI works fine with C openssl).

An urgent workaround would also be amazing, if possible <3 I've been playing with something like this but with little success so far:

    uri = URI.parse(ds_url)
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.ssl_version = :"TLSv1_2"
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE # OpenSSL::SSL::VERIFY_PEER, OpenSSL::SSL::VERIFY_NONE
    http.cert = client_cert
    http.key = client_key
    http.ca_file = ds_cert_file
    http.ciphers = OpenSSL::SSL::SSLContext.new.ciphers.map do |c|
      c[0].gsub("-", "+")
    end
    puts http.ciphers.inspect

    resp = http.post(uri.request_uri, http_body, 'Content-Type' => 'application/xml; charset=utf-8')
    resp.body

that said, the response is always OpenSSL::SSL::SSLError: Socket closed, the openssl s_client command with this same data plugged in works, and it works when MRI ruby is used.

these are the currently active ciphers:

["EXP+DES+CBC+SHA", "EXP+EDH+RSA+DES+CBC+SHA", "EXP+EDH+DSS+DES+CBC+SHA", "DES+CBC+SHA", "EDH+RSA+DES+CBC+SHA", "ECDHE+ECDSA+AES128+SHA256", "ECDHE+RSA+AES128+SHA256", "ECDH+ECDSA+AES128+SHA256", "ECDH+RSA+AES128+SHA256", "ECDHE+ECDSA+AES128+SHA", "ECDHE+RSA+AES128+SHA", "AES128+SHA", "ECDH+ECDSA+AES128+SHA", "ECDH+RSA+AES128+SHA", "DHE+RSA+AES128+SHA", "DHE+DSS+AES128+SHA", "ECDHE+ECDSA+DES+CBC3+SHA", "ECDHE+RSA+DES+CBC3+SHA", "DES+CBC3+SHA", "ECDH+ECDSA+DES+CBC3+SHA", "ECDH+RSA+DES+CBC3+SHA", "EDH+RSA+DES+CBC3+SHA", "EDH+DSS+DES+CBC3+SHA", "ECDHE+ECDSA+AES256+SHA384", "ECDHE+RSA+AES256+SHA384", "ECDH+ECDSA+AES256+SHA384", "ECDH+RSA+AES256+SHA384", "ECDHE+ECDSA+AES256+SHA", "ECDHE+RSA+AES256+SHA", "AES256+SHA", "ECDH+ECDSA+AES256+SHA", "ECDH+RSA+AES256+SHA", "DHE+RSA+AES256+SHA", "DHE+DSS+AES256+SHA"]

Ruby is jruby 9.1.13.0 (2.3.3)

PS actually, any of these would be a life-saver:

ECDHE-RSA-AES256-GCM-SHA384 TLS1.2
ECDHE-RSA-AES256-SHA384 TLS1.2
ECDHE-RSA-AES256-CBC-SHA TLS1.2
ECDHE-ECDSA-AES256-SHA384 TLS1.2
ECDHE-ECDSA-AES256-SHA TLS1.2
ECDH-RSA-AES256-SHA384 TLS1.2
ECDH-ECDSA-AES256-SHA384 TLS1.2
ECDH-RSA-AES256-SHA TLS1.2
ECDH-ECDSA-AES256-SHA TLS1.2
@kares
Copy link
Member

kares commented Jun 28, 2018

if its supported by the underlying Java engine than it should be doable.
its mostly a matter of looking into the Java->OSSL mapping to show up ...

@mattbooks
Copy link

#126 and this commit added Java -> OSSL mappings for the IBM JRE version of these ciphers (SSL_ prefix instead of TLS_ prefix) but most don't have matching definitions in CipherNames, which means they will never be used. I managed to add a mapping that I needed to CipherNames and I'm able to successfully open SSL sockets with it, but I just guessed on what to put in the algorithms field in the Def class for the mapping. Looking into this further in an attempt to add more of these mappings reveals a couple of issues:

  1. The ssl version string format differs between jruby and mri. In jruby it is always TLSv1/SSLv3 (running from java8). In mri it is one of ["TLSv1.2", "TLSv1.0", "SSLv3"]. While it seems to work without fixing this, it's probably not the best idea to leave it alone.
  2. The Def struct in jruby uses an algorithms bitmask. It's hard to correlate that to openssl, since they seem to have broken that out into 4 fields in version 1.0.0. It seems to be only really used for that ssl version string however, and I'm not sure what that version string actually gets used for. So for example, I have no idea if I need to set or if so what to set to indicate that the cipher uses GCM.
  3. Several CipherNames mappings don't have Java -> OSSL mappings, so I'm not sure how they are ever used.

jruby/jruby#1738 has previous discussion about this issue

Here are some commits that refactor CipherStrings to illustrate what cipher mappings are missing: mattbooks#1

@mattbooks
Copy link

#177 adds support for ECDHE-RSA-AES128-GCM-SHA256

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

No branches or pull requests

3 participants