2

Is there a way to force SSL version on a single RestClient connection?

I need to set it to 'SSLv3'.

I'm able to do that for ALL connections using:

OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:ssl_version] = 'SSLv3'

But that of course is too global.

When trying to pass parameters in the initialization, it doesn't work:

RestClient::Resource.new('https://example.com',:ssl_version => "SSLv3")
Rizon
  • 1,516
  • 4
  • 25
  • 45
  • Technically, you can't use OpenSSL method above to set the encryption for all connections. SSLv3 is hard-coded in RestClient. https://github.com/treeder/rest_client/blob/master/lib/restclient/request.rb#L59 (at least for the gem'd version) – jmar Oct 15 '14 at 23:11

1 Answers1

3

You can use an invocation like this:

RestClient::Request.execute(:url => 'https://example.com', :ssl_version => 'SSLv3', :method => 'get')

But note that older versions of rest-client would silently discard the :ssl_version option. You can test whether this is happening by using a bogus SSL version:

>> RestClient::Request.execute(:url => 'https://example.com', :ssl_version => 'blah', :method => 'get')
ArgumentError: unknown SSL method `blah'.
from /usr/lib/ruby/1.9.1/openssl/ssl-internal.rb:38:in `ssl_version='
A B
  • 8,340
  • 2
  • 31
  • 35