Skip to content

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

@marshalium

Description

@marshalium

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions