ruby / openssl

Provides SSL, TLS and general purpose cryptography.
Other
241 stars 163 forks source link

OpenSSL::SSL::SSLError: SSL_write: unsupported method #738

Open hari-sangani opened 6 months ago

hari-sangani commented 6 months ago

Hello 👋

When establishing a connection to Azure Cache for Redis using ssl option, encountering this error.

OpenSSL::SSL::SSLError: SSL_write: unsupported method
from openssl/buffering.rb:415:in 'syswrite_nonblock'
from openssl/buffering.rb:415:in 'write_nonblock'
from redis-client (0.20.0) lib/redis_client/ruby_connection/buffered_io.rb:64:in 'block in write'
from redis-client (0.20.0) lib/redis_client/ruby_connection/buffered_io.rb:63:in 'loop'
from redis-client (0.20.0) lib/redis_client/ruby_connection/buffered_io.rb:63:in 'write'
from redis-client (0.20.0) lib/redis_client/ruby_connection.rb:74:in 'write'
from redis-client (0.20.0) lib/redis_client/connection_mixin.rb:30:in 'call'
from redis-client (0.20.0) lib/redis_client.rb:272:in 'block (2 levels) in call_v'
from redis-client (0.20.0) lib/redis_client/middlewares.rb:16:in 'call'
from redis-client (0.20.0) lib/redis_client.rb:271:in 'block in call_v'
from redis-client (0.20.0) lib/redis_client.rb:677:in 'ensure_connected'
from redis-client (0.20.0) lib/redis_client.rb:270:in 'call_v'
from redis (5.1.0) lib/redis/client.rb:90:in 'call_v'
from redis (5.1.0) lib/redis.rb:152:in 'block in send_command'
from redis (5.1.0) lib/redis.rb:151:in 'synchronize'
from redis (5.1.0) lib/redis.rb:151:in 'send_command'
from redis (5.1.0) lib/redis/commands/strings.rb:191:in 'get'
from activesupport (6.1.7.3) lib/active_support/cache/redis_cache_store.rb:349:in 'block (2 levels) in read_entry'
from redis (5.1.0) lib/redis.rb:95:in 'with'
from activesupport (6.1.7.3) lib/active_support/cache/redis_cache_store.rb:349:in 'block in read_entry'
from activesupport (6.1.7.3) lib/active_support/cache/redis_cache_store.rb:478:in 'failsafe'
from activesupport (6.1.7.3) lib/active_support/cache/redis_cache_store.rb:347:in 'read_entry'
from activesupport (6.1.7.3) lib/active_support/cache/strategy/local_cache.rb:136:in 'block in read_entry'
from activesupport (6.1.7.3) lib/active_support/cache/strategy/local_cache.rb:78:in 'block in fetch_entry'
from activesupport (6.1.7.3) lib/active_support/cache/strategy/local_cache.rb:78:in 'fetch'
from activesupport (6.1.7.3) lib/active_support/cache/strategy/local_cache.rb:78:in 'fetch_entry'
from activesupport (6.1.7.3) lib/active_support/cache/strategy/local_cache.rb:134:in 'read_entry'
from activesupport (6.1.7.3) lib/active_support/cache.rb:333:in 'block in fetch'
from activesupport (6.1.7.3) lib/active_support/cache.rb:726:in 'block in instrument'
from activesupport (6.1.7.3) lib/active_support/notifications.rb:203:in 'block in instrument'
from activesupport (6.1.7.3) lib/active_support/notifications/instrumenter.rb:24:in 'instrument'
from activesupport (6.1.7.3) lib/active_support/notifications.rb:203:in 'instrument'
from activesupport (6.1.7.3) lib/active_support/cache.rb:726:in 'instrument'
from activesupport (6.1.7.3) lib/active_support/cache.rb:332:in 'fetch'

Redis 6.0.4 OpenSSL 3.0.11 Ruby 3.1.1 Rails 6.1.7.3

rhenium commented 5 months ago

Is there any way to reproduce the error? Do you happen to use an OpenSSL engine or provider?

The error message "unsupported method" likely belongs to OpenSSL BIO API, but it doesn't seem to be normal to appear here.

hari-sangani commented 4 months ago

This issue occasionally occurs while connecting to the Redis server on Azure, but it works fine when using OpenSSL version 1.1.1w.

rhenium commented 4 months ago

Could you provide a reproducer that I can run? The error message is unusual and I want to look into it.

hari-sangani commented 4 months ago

To reproduce the error, you'll need to set up a Redis server that requires an SSL connection, such as Azure Redis Cache(set ssl=true here). Configure your project to connect to this Redis instance.

For example, you can use the latest Docker image for Ruby 3.1, which includes OpenSSL version 3.0.9, and attempt to execute a fetch command, you might encounter the error.

If it succeeds initially, wait for 5-10 minutes, then execute the same command again. You should encounter the error at that point.