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

'ssl-tcp' protocol enforces the use of ssl_cert with no error handling #42

Open
makenowjust opened this issue Nov 1, 2017 · 3 comments · May be fixed by #43
Open

'ssl-tcp' protocol enforces the use of ssl_cert with no error handling #42

makenowjust opened this issue Nov 1, 2017 · 3 comments · May be fixed by #43

Comments

@makenowjust
Copy link

This project has just the same issue as logstash-plugins/logstash-output-tcp#22.

config:

input {
    stdin { }
}

output {
    syslog {
        host => "localhost"
        port => 9000
        protocol => "ssl-tcp"
        ssl_cacert => "./ca_cert.pem"
    }
}

output:

[2017-11-01T15:14:25,029][ERROR][logstash.agent           ] Pipeline aborted due to error {:exception=>#<TypeError: can't convert nil into String>, :backtrace=>["org/jruby/RubyIO.java:3804:in `read'", "org/jruby/RubyIO.java:3987:in `read'", "/usr/local/Cellar/logstash/5.6.2/libexec/vendor/bundle/jruby/1.9/gems/logstash-output-syslog-3.0.3/lib/logstash/outputs/syslog.rb:229:in `setup_ssl'", "/usr/local/Cellar/logstash/5.6.2/libexec/vendor/bundle/jruby/1.9/gems/logstash-output-syslog-3.0.3/lib/logstash/outputs/syslog.rb:132:in `register'", "org/jruby/RubyArray.java:1613:in `each'", "/usr/local/Cellar/logstash/5.6.2/libexec/logstash-core/lib/logstash/output_delegator_strategies/legacy.rb:17:in `register'", "/usr/local/Cellar/logstash/5.6.2/libexec/logstash-core/lib/logstash/output_delegator.rb:43:in `register'", "/usr/local/Cellar/logstash/5.6.2/libexec/logstash-core/lib/logstash/pipeline.rb:290:in `register_plugin'", "/usr/local/Cellar/logstash/5.6.2/libexec/logstash-core/lib/logstash/pipeline.rb:301:in `register_plugins'", "org/jruby/RubyArray.java:1613:in `each'", "/usr/local/Cellar/logstash/5.6.2/libexec/logstash-core/lib/logstash/pipeline.rb:301:in `register_plugins'", "/usr/local/Cellar/logstash/5.6.2/libexec/logstash-core/lib/logstash/pipeline.rb:310:in `start_workers'", "/usr/local/Cellar/logstash/5.6.2/libexec/logstash-core/lib/logstash/pipeline.rb:235:in `run'", "/usr/local/Cellar/logstash/5.6.2/libexec/logstash-core/lib/logstash/agent.rb:398:in `start_pipeline'"]}

And I think logstash-plugins/logstash-output-tcp#31 can be ported to this project to solve this issue. Thank you.

makenowjust added a commit to makenowjust/logstash-output-syslog that referenced this issue Nov 6, 2017
@makenowjust makenowjust linked a pull request Nov 6, 2017 that will close this issue
@limdauto
Copy link

Could someone merge the fix for this please? I really need it.

@willscavforlabkeys
Copy link

5 years later....

@msbart29
Copy link

msbart29 commented Apr 6, 2023

I didn't understand why ssl_cert and ssl_key are required when "ssl-tcp" mode si set ...
To fix-it, I editied the syslog.rb file. (Logstash 7.17.3 - syslog output 3.0.5)
Below the patch to apply

+++ /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-syslog-3.0.5/lib/logstash/outputs/syslog.rb      2023-04-06 15:58:56.425639990 +0200
@@ -226,8 +226,12 @@
   def setup_ssl
     require "openssl"
     ssl_context = OpenSSL::SSL::SSLContext.new
-    ssl_context.cert = OpenSSL::X509::Certificate.new(File.read(@ssl_cert))
-    ssl_context.key = OpenSSL::PKey::RSA.new(File.read(@ssl_key),@ssl_key_passphrase)
+    if @ssl_cert and File.file?(@ssl_cert)
+      ssl_context.cert = OpenSSL::X509::Certificate.new(File.read(@ssl_cert))
+    end
+    if @ssl_key and File.file?(@ssl_key)
+      ssl_context.key = OpenSSL::PKey::RSA.new(File.read(@ssl_key),@ssl_key_passphrase)
+    end
     if @ssl_verify
       cert_store = OpenSSL::X509::Store.new
       # Load the system default certificate path to the store

Regards

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.

4 participants