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

NullPointerException in PKeyEC.java when calling Net::SSH.start #105

Closed
marshalium opened this issue Sep 23, 2016 · 14 comments
Closed

NullPointerException in PKeyEC.java when calling Net::SSH.start #105

marshalium opened this issue Sep 23, 2016 · 14 comments
Assignees

Comments

@marshalium
Copy link

marshalium commented Sep 23, 2016

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.

@steveh
Copy link

steveh commented Oct 13, 2016

@marshalium mind sharing exactly what you did to hack around net/ssh? I tried this which didn't seem to work:

Net::SSH::Transport::Algorithms::ALGORITHMS = Net::SSH::Transport::Algorithms::ALGORITHMS.each_with_object({}) do |(option, values), result|
  result[option] = values.reject { |value| value =~ /ecd/ }
end

Net::SSH::KnownHosts::SUPPORTED_TYPE = Net::SSH::KnownHosts::SUPPORTED_TYPE.reject { |value| value =~ /ecd/ }

@marshalium
Copy link
Author

Interesting. What I did was similar, but I modified the objects directly instead of changing the constant. This works for me:

Net::SSH::Transport::Algorithms::ALGORITHMS.values.each { |algs| algs.reject! { |a| a =~ /^ecd(sa|h)-sha2/ } }
Net::SSH::KnownHosts::SUPPORTED_TYPE.reject! { |t| t =~ /^ecd(sa|h)-sha2/ }

@aditya-sanghi
Copy link

@steveh @marshalium is there any conclusion for this issue? I am facing the same on Jruby 9.1.6.0

@kares
Copy link
Member

kares commented Apr 11, 2017

no conclusion - EC support isn't finished as noted on the original issue: jruby/jruby#4129 (comment)

@thbar
Copy link

thbar commented 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
Copy link

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
Copy link

thbar commented 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
Copy link

@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
Copy link
Member

headius commented Jun 11, 2020

I've got this in my queue and will hopefully look into it this week.

@headius headius self-assigned this Jun 11, 2020
@redconfetti
Copy link

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
Copy link
Member

headius commented 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
Copy link

silkPK commented Sep 9, 2022

ctualy, with Net::SSH 7.0.1 the error reported is

NoMethodError (undefined method generate' for OpenSSL::PKey::EC:Class)`

#255

@kares
Copy link
Member

kares commented 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 a Group object...

@kares
Copy link
Member

kares commented Apr 11, 2024

with 21c93d8 (in 0.14.4) I am calling this one fixes

@kares kares closed this as completed Apr 11, 2024
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

9 participants