-
Notifications
You must be signed in to change notification settings - Fork 81
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
java.security.InvalidKeyException when upgrading to Logstash 6.3.2 #92
Comments
Hi @MikeKemmerer Can you share your configuration (removing any sensitive information)? From the stack trace, it looks like you might be using a client cert - if so, can you also share how the client cert/key were created |
Here's the configuration:
Here's How I'm creating my key and CSR:
My org is creating the certificate using an internal CA |
I am getting the same error with Logstash 6.6.0 when I use an RSA-encoded private key. My output configuration:
Error:
|
This is still an issue with more recent Logstash versions and plugins. Tested with Logstash version 8.4.2. |
@borissnd Can you be more specific? I checked the affected private keys, but I can't the mentioned whitespaces. When I exactly know where to look at, I can check the private keys when they are created and recreate if needed. |
Strip removes all whitespace characters, not just line breaks and spaces (null, horizontal tab, line feed, vertical tab, form feed, carriage return, space). If a certificate starts or ends with such a character, a Java::JavaSecuritySpec::InvalidKeySpecException is thrown. For example, this [issue](logstash-plugins/logstash-output-http#92) results from this bug.
Since upgrading from Logstash 6.3.0 to 6.3.2 and from version 5.2.1 to version 5.2.2 of this plugin, I began experiencing this error when outputting data via the http output plugin. I'm running RedHat 7 and java is: java-1.8.0-openjdk-headless-1.8.0.181-3.b13.el7_5.x86_64
The error persisted after downgrading to version 5.2.1 of the plugin. After downgrading from 6.3.2 down to 6.3.0, the issue went away without changing anything else.
Thanks.
[2018-08-23T22:06:48,376][ERROR][logstash.outputs.http ] Error in http output loop {:class=>"Java::JavaSecuritySpec::InvalidKeySpecException", :message=>"java.security.InvalidKeyException: IOException : algid parse error, not a sequence", :backtrace=>["sun.security.rsa.RSAKeyFactory.engineGeneratePrivate(sun/security/rsa/RSAKeyFactory.java:217)", "java.security.KeyFactory.generatePrivate(java/security/KeyFactory.java:372)", "java.lang.reflect.Method.invoke(java/lang/reflect/Method.java:498)", "org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(org/jruby/javasupport/JavaMethod.java:453)", "org.jruby.javasupport.JavaMethod.invokeDirect(org/jruby/javasupport/JavaMethod.java:314)", "RUBY.block in setup_key_store(/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/manticore-0.6.4-java/lib/manticore/client.rb:681)", "org.jruby.RubyArray.each(org/jruby/RubyArray.java:1734)", "org.jruby.RubyArray$INVOKER$i$0$0$each.call(org/jruby/RubyArray$INVOKER$i$0$0$each.gen)", "RUBY.setup_key_store(/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/manticore-0.6.4-java/lib/manticore/client.rb:676)", "RUBY.ssl_socket_factory_from_options(/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/manticore-0.6.4-java/lib/manticore/client.rb:622)", "RUBY.pool_builder(/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/manticore-0.6.4-java/lib/manticore/client.rb:397)", "RUBY.pool(/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/manticore-0.6.4-java/lib/manticore/client.rb:405)", "RUBY.initialize(/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/manticore-0.6.4-java/lib/manticore/client.rb:209)", "org.jruby.RubyClass.newInstance(org/jruby/RubyClass.java:1001)", "org.jruby.RubyClass$INVOKER$i$newInstance.call(org/jruby/RubyClass$INVOKER$i$newInstance.gen)", "RUBY.make_client(/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-mixin-http_client-6.0.1/lib/logstash/plugin_mixins/http_client.rb:180)", "RUBY.client(/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-mixin-http_client-6.0.1/lib/logstash/plugin_mixins/http_client.rb:185)", "RUBY.send_event(/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-output-http-5.2.1/lib/logstash/outputs/http.rb:259)", "RUBY.send_events(/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-output-http-5.2.1/lib/logstash/outputs/http.rb:194)", "RUBY.multi_receive(/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-output-http-5.2.1/lib/logstash/outputs/http.rb:124)", "org.jruby.RubyClass.finvoke(org/jruby/RubyClass.java:908)", "org.jruby.RubyBasicObject.callMethod(org/jruby/RubyBasicObject.java:363)", "org.logstash.config.ir.compiler.OutputStrategyExt$SimpleAbstractOutputStrategyExt.doOutput(org/logstash/config/ir/compiler/OutputStrategyExt.java:219)", "org.logstash.config.ir.compiler.OutputStrategyExt$SharedOutputStrategyExt.output(org/logstash/config/ir/compiler/OutputStrategyExt.java:247)", "org.logstash.config.ir.compiler.OutputStrategyExt$AbstractOutputStrategyExt.multi_receive(org/logstash/config/ir/compiler/OutputStrategyExt.java:109)", "org.logstash.config.ir.compiler.OutputDelegatorExt.multi_receive(org/logstash/config/ir/compiler/OutputDelegatorExt.java:156)", "org.logstash.config.ir.compiler.OutputDelegatorExt$INVOKER$i$1$0$multiReceive.call(org/logstash/config/ir/compiler/OutputDelegatorExt$INVOKER$i$1$0$multiReceive.gen)", "usr.share.logstash.logstash_minus_core.lib.logstash.pipeline.invokeOther5:multi_receive(usr/share/logstash/logstash_minus_core/lib/logstash//usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:475)", "usr.share.logstash.logstash_minus_core.lib.logstash.pipeline.block in output_batch(/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:475)", "org.jruby.RubyHash$12.visit(org/jruby/RubyHash.java:1362)", "org.jruby.RubyHash$12.visit(org/jruby/RubyHash.java:1359)", "org.jruby.RubyHash.visitLimited(org/jruby/RubyHash.java:662)", "org.jruby.RubyHash.visitAll(org/jruby/RubyHash.java:647)", "org.jruby.RubyHash.iteratorVisitAll(org/jruby/RubyHash.java:1319)", "org.jruby.RubyHash.each_pairCommon(org/jruby/RubyHash.java:1354)", "org.jruby.RubyHash.each(org/jruby/RubyHash.java:1343)", "org.jruby.RubyHash$INVOKER$i$0$0$each.call(org/jruby/RubyHash$INVOKER$i$0$0$each.gen)", "usr.share.logstash.logstash_minus_core.lib.logstash.pipeline.invokeOther11:each(usr/share/logstash/logstash_minus_core/lib/logstash//usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:474)", "usr.share.logstash.logstash_minus_core.lib.logstash.pipeline.output_batch(/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:474)", "RUBY.worker_loop(/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:426)", "RUBY.block in start_workers(/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:384)", "org.jruby.RubyProc.call(org/jruby/RubyProc.java:289)", "org.jruby.RubyProc.call(org/jruby/RubyProc.java:246)", "java.lang.Thread.run(java/lang/Thread.java:748)"]}
The text was updated successfully, but these errors were encountered: