dwbutler / logstash-logger

Ruby logger that writes logstash events
MIT License
456 stars 119 forks source link

ssl_enable: true used alone raise an exception #144

Closed collimarco closed 6 years ago

collimarco commented 6 years ago

The readme describes the following configuration:

LogStashLogger.new(type: :tcp, host: 'listener.logz.io', port: 5000, ssl_enable: true)

However that raise an exception:

ERROR -- : [LogStashLogger::Device::TCP] TypeError - wrong argument (NilClass)! (Expected kind of OpenSSL::SSL::SSLContext)

When ssl_context is not passed explicitly, you probably need to create an ssl_context automatically with VERIFY_PEER.

collimarco commented 6 years ago

The problem is also relevant for the Rails integration when you use:

config.logstash.ssl_enable = true
dwbutler commented 6 years ago

After some investigation, I have discovered that this is a new problem starting with Ruby 2.4. The behavior of OpenSSL::SSL::SSLSocket::new has changed. In Ruby <= 2.3, the method signature is new(io, ctx = nil). In Ruby 2.4+, you must pass either one argument or both. You can't pass a nil context.

dwbutler commented 6 years ago

Fix released in 0.26.1.