Skip to content

SSLContext#ciphers= exposes internal exceptions #220

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

Closed
p-mongo opened this issue Nov 19, 2020 · 1 comment · Fixed by #223
Closed

SSLContext#ciphers= exposes internal exceptions #220

p-mongo opened this issue Nov 19, 2020 · 1 comment · Fixed by #223
Milestone

Comments

@p-mongo
Copy link

p-mongo commented Nov 19, 2020

If I try to assign ciphers to an empty array or an array containing nil, I get a Java::JavaLang::StringIndexOutOfBoundsException.

I expected either an OpenSSL error or a Ruby standard library error in this case.

irb(main):017:0> c=OpenSSL::SSL::SSLContext.new
=> #<OpenSSL::SSL::SSLContext:0x20d87335>
irb(main):018:0> c.ciphers=[]
Traceback (most recent call last):
       16: from org.jruby.RubyKernel.eval(RubyKernel.java:1048)
       15: from org.jruby.RubyKernel.evalCommon(RubyKernel.java:1086)
       14: from org.jruby.ir.interpreter.Interpreter.evalWithBinding(Interpreter.java:182)
       13: from org.jruby.ir.interpreter.Interpreter.evalCommon(Interpreter.java:158)
       12: from org.jruby.ir.interpreter.Interpreter.INTERPRET_EVAL(Interpreter.java:106)
       11: from org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:72)
       10: from org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:361)
        9: from org.jruby.ir.instructions.specialized.OneArgOperandAttrAssignInstr.interpret(OneArgOperandAttrAssignInstr.java:37)
        8: from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:174)
        7: from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:375)
        6: from org.jruby.ext.openssl.SSLContext$INVOKER$i$1$0$set_ciphers.call(SSLContext$INVOKER$i$1$0$set_ciphers.gen)
        5: from org.jruby.ext.openssl.SSLContext.set_ciphers(SSLContext.java:506)
        4: from org.jruby.ext.openssl.SSLContext.matchedCiphers(SSLContext.java:469)
        3: from org.jruby.ext.openssl.CipherStrings.matchingCiphers(CipherStrings.java:515)
        2: from java.base/java.lang.String.charAt(String.java:693)
        1: from java.base/java.lang.StringLatin1.charAt(StringLatin1.java:47)
Java::JavaLang::StringIndexOutOfBoundsException (String index out of range: 0)
irb(main):019:0> c.ciphers=[nil]
Traceback (most recent call last):
       16: from org.jruby.RubyKernel.eval(RubyKernel.java:1048)
       15: from org.jruby.RubyKernel.evalCommon(RubyKernel.java:1086)
       14: from org.jruby.ir.interpreter.Interpreter.evalWithBinding(Interpreter.java:182)
       13: from org.jruby.ir.interpreter.Interpreter.evalCommon(Interpreter.java:158)
       12: from org.jruby.ir.interpreter.Interpreter.INTERPRET_EVAL(Interpreter.java:106)
       11: from org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:72)
       10: from org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:361)
        9: from org.jruby.ir.instructions.specialized.OneArgOperandAttrAssignInstr.interpret(OneArgOperandAttrAssignInstr.java:37)
        8: from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:174)
        7: from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:375)
        6: from org.jruby.ext.openssl.SSLContext$INVOKER$i$1$0$set_ciphers.call(SSLContext$INVOKER$i$1$0$set_ciphers.gen)
        5: from org.jruby.ext.openssl.SSLContext.set_ciphers(SSLContext.java:506)
        4: from org.jruby.ext.openssl.SSLContext.matchedCiphers(SSLContext.java:469)
        3: from org.jruby.ext.openssl.CipherStrings.matchingCiphers(CipherStrings.java:515)
        2: from java.base/java.lang.String.charAt(String.java:693)
        1: from java.base/java.lang.StringLatin1.charAt(StringLatin1.java:47)
Java::JavaLang::StringIndexOutOfBoundsException (String index out of range: 0)

jruby 9.2.13.0 (2.5.7) 2020-08-03 9a89c94bcc OpenJDK 64-Bit Server VM 11.0.9+11-post-Debian-1 on 11.0.9+11-post-Debian-1 +jit [linux-x86_64]

@p-mongo
Copy link
Author

p-mongo commented Nov 27, 2020

MRI behavior:

serene% irb -ropenssl
irb(main):001:0> c=OpenSSL::SSL::SSLContext.new
=> #<OpenSSL::SSL::SSLContext:0x0000558711862638>
irb(main):002:0> c.ciphers=[]
Traceback (most recent call last):
        5: from /home/w/.rbenv/versions/2.7/bin/irb:23:in `<main>'
        4: from /home/w/.rbenv/versions/2.7/bin/irb:23:in `load'
        3: from /home/w/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/irb-1.2.6/exe/irb:11:in `<top (required)>'
        2: from (irb):2
        1: from (irb):2:in `ciphers='
OpenSSL::SSL::SSLError (SSL_CTX_set_cipher_list: no cipher match)

@headius headius added this to the 0.10.5 milestone Dec 2, 2020
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 a pull request may close this issue.

2 participants