Repository navigation
Description
Moved from the jruby issue tracker: jruby/jruby/issues/4129
Environment
$ jruby -v
jruby 9.1.4.0 (2.3.1) 2016-09-01 2e1327f Java HotSpot(TM) 64-Bit Server VM 25.77-b03 on 1.8.0_77-b03 +jit [darwin-x86_64]
$ uname -a
Darwin marshall-work-lappy.local 15.6.0 Darwin Kernel Version 15.6.0: Thu Jun 23 18:25:34 PDT 2016; root:xnu-3248.60.10~1/RELEASE_X86_64 x86_64
Expected Behavior
Net::SSH.start should be able connect to an SSH server that supports ecdsa-sha2-nistp256 without raising any errors. This worked in 9.1.2.0, but I believe it was because that class of algorithms was not supported (I think because OpenSSL::PKey::EC did not exist at all).
Actual Behavior
irb(main):001:0> require 'net/ssh'
=> true
irb(main):002:0> Gem.loaded_specs['net-ssh'].version
=> #<Gem::Version "3.2.0">
irb(main):003:0> RUBY_DESCRIPTION
=> "jruby 9.1.4.0 (2.3.1) 2016-09-01 2e1327f Java HotSpot(TM) 64-Bit Server VM 25.77-b03 on 1.8.0_77-b03 +jit [darwin-x86_64]"
irb(main):004:0> Net::SSH.start("some-server.example.com", "some_username")
Java::JavaLang::NullPointerException:
from org.jruby.ext.openssl.PKeyEC$Point.initialize(PKeyEC.java:836)
from org.jruby.ext.openssl.PKeyEC$Point$INVOKER$i$0$0$initialize.call(PKeyEC$Point$INVOKER$i$0$0$initialize.gen)
from org.jruby.internal.runtime.methods.JavaMethod$JavaMethodN.call(JavaMethod.java:724)
from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:368)
from org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:205)
from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:209)
from org.jruby.RubyClass.newInstance(RubyClass.java:999)
from org.jruby.RubyClass$INVOKER$i$newInstance.call(RubyClass$INVOKER$i$newInstance.gen)
from org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:205)
from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:358)
from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:195)
from org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:324)
from org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:73)
from org.jruby.ir.interpreter.InterpreterEngine.interpret(InterpreterEngine.java:90)
from org.jruby.internal.runtime.methods.MixedModeIRMethod.INTERPRET_METHOD(MixedModeIRMethod.java:214)
from org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:200)
... 335 levels...
from org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:201)
from org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:197)
from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:338)
from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:163)
from Users.mscorcio.$_dot_rbenv.versions.jruby_minus_9_dot_1_dot_4_dot_0.bin.bundle.invokeOther18:load(/Users/mscorcio/.rbenv/versions/jruby-9.1.4.0/bin/bundle:22)
from Users.mscorcio.$_dot_rbenv.versions.jruby_minus_9_dot_1_dot_4_dot_0.bin.bundle.RUBY$script(/Users/mscorcio/.rbenv/versions/jruby-9.1.4.0/bin/bundle:22)
from java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)
from org.jruby.ir.Compiler$1.load(Compiler.java:111)
from org.jruby.Ruby.runScript(Ruby.java:834)
from org.jruby.Ruby.runNormally(Ruby.java:749)
from org.jruby.Ruby.runNormally(Ruby.java:767)
from org.jruby.Ruby.runFromMain(Ruby.java:580)
from org.jruby.Main.doRunFromMain(Main.java:425)
from org.jruby.Main.internalRun(Main.java:313)
from org.jruby.Main.run(Main.java:242)
from org.jruby.Main.main(Main.java:204)
If I hack net-ssh to exclude all the ecd* algorithms from Net::SSH::Transport::Algorithms::ALGORITHMS and Net::SSH::KnownHosts::SUPPORTED_TYPE I am able to connect to the same server without error.
Also using MRI 2.2.4 and the same version of net-ssh I am able to connect to the same server without error.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Activity
steveh commentedon Oct 13, 2016
@marshalium mind sharing exactly what you did to hack around net/ssh? I tried this which didn't seem to work:
marshalium commentedon Oct 17, 2016
Interesting. What I did was similar, but I modified the objects directly instead of changing the constant. This works for me:
aditya-sanghi commentedon Apr 10, 2017
@steveh @marshalium is there any conclusion for this issue? I am facing the same on Jruby 9.1.6.0
kares commentedon Apr 11, 2017
no conclusion - EC support isn't finished as noted on the original issue: jruby/jruby#4129 (comment)
thbar commentedon Apr 11, 2017
@aditya-sanghi in case it helps, I faced this with JRuby 9.1.7.0 and can confirm the tip provided above by @marshalium helped me deploy with Capistrano (which otherwise fails).
rahul100885 commentedon May 21, 2020
Does any update on this, since I am still facing this issue.
I have tried jruby-9.1.17.0 and jruby-9.2.11.1 with net-ssh 6.0.2.
Tried @marshalium solution but no luck.
thbar commentedon May 21, 2020
@rahul100885 just a bit of feedback in case it helps: the solution you quoted works at least for me today with net-ssh 5.2.0 and jruby 9.2.5.0 (via net/sftp). I haven't tested with more recent version of jruby and net-ssh yet, though!
rahul100885 commentedon May 21, 2020
@thbar I tried with net-ssh 5.2.0 with jruby-9.1.17.0 and jruby-9.2.11.1 but no luck. Trying to install jruby 9.2.5.0 with rbenv but facing issue in download.
headius commentedon Jun 11, 2020
I've got this in my queue and will hopefully look into it this week.
redconfetti commentedon Sep 23, 2020
I found that this issue doesn't occur with jruby 9.2.13.0 when using Net-SSH v5.0.2. Any version after that (v5.1.0) gets the
Java::JavaLang::NullPointerException ()error.headius commentedon Dec 2, 2020
I assume the newer net-ssh is just doing additional calls that are not properly supported. This is still an issue, but not sure when we can get someone to work on it...
silkPK commentedon Sep 9, 2022
ctualy, with Net::SSH 7.0.1 the error reported is
NoMethodError (undefined methodgenerate' for OpenSSL::PKey::EC:Class)`#255
kares commentedon Feb 21, 2024
last error ^^^ was resolved in 0.14.3 and is not related to the original report.
the reported issue might still persist, if I got it right historically it's been due this line
which, still, happens if the
Point.new(arg1, arg2)is used and the first argument isn't aGroupobject...kares commentedon Apr 11, 2024
with 21c93d8 (in 0.14.4) I am calling this one fixes