openssl icon indicating copy to clipboard operation
openssl copied to clipboard

OpenSSL::SSL::SSLError: SSL_write: unsupported method

Open hari-sangani opened this issue 1 year ago • 4 comments

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

hari-sangani avatar Mar 28 '24 09:03 hari-sangani

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.

rhenium avatar Apr 26 '24 17:04 rhenium

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

hari-sangani avatar May 08 '24 04:05 hari-sangani

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

rhenium avatar May 08 '24 09:05 rhenium

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.

hari-sangani avatar May 08 '24 09:05 hari-sangani

Closing this issue for now. Please reopen if this is still an issue with current versions of ruby/openssl and OpenSSL, but we'll need a reproducer that runs locally.

rhenium avatar Nov 26 '25 12:11 rhenium