ruby 2.4 rest-client 1.8 error

错误信息:

KeyError: key not found: :ciphers

from /Users/mike/.rvm/gems/ruby-2.4.0@sa/gems/rest-client-1.8.0/lib/restclient/request.rb:163:in `fetch'

from /Users/mike/.rvm/gems/ruby-2.4.0@sa/gems/rest-client-1.8.0/lib/restclient/request.rb:163:in `initialize'

from /Users/mike/.rvm/gems/ruby-2.4.0@sa/gems/rest-client-1.8.0/lib/restclient/request.rb:41:in `new'

from /Users/mike/.rvm/gems/ruby-2.4.0@sa/gems/rest-client-1.8.0/lib/restclient/request.rb:41:in `execute'

原因:

https://github.com/rest-client/rest-client/issues/569

RestClient checks for weak ciphers onOpenSSL::SSL::SSLContext::DEFAULT_PARAMSbut ciphers param was removed from the defaults for openssl 2.0 built with OpenSSL version 1.1.0 or newer, since it was a workaround for OpenSSL bad DEFAULT. See PRruby/openssl#66

So for ruby 2.4 and openssl 2.0.2 built with OpenSSL 1.1.0 I'm gettingKeyError: key not found: :ciphers.

One way of checking for default ciphers with openssl built with OpenSSL 1.1.0 is

OpenSSL::SSL::SSLContext.new.ciphers.map { |v,_,_,_,_| v }.join(':')




修改:

参考:

https://github.com/rest-client/rest-client/pull/572/commits/ec58882a81f2ca6a8d1944d090dfdc71c58a9b49


注释这两行,

ifWeakDefaultCiphers.include?(

OpenSSL::SSL::SSLContext::DEFAULT_PARAMS.fetch(:ciphers))

修改为:

ifdefined?(OpenSSL::OPENSSL_LIBRARY_VERSION)&&

OpenSSL::OPENSSL_LIBRARY_VERSION.start_with?("OpenSSL 1.1")

            ciphers=OpenSSL::SSL::SSLContext.new.ciphers.map(&:first).join(':')

else

            ciphers=OpenSSL::SSL::SSLContext::DEFAULT_PARAMS.fetch(:ciphers)

end

ifWeakDefaultCiphers.include?(ciphers)

你可能感兴趣的:(ruby 2.4 rest-client 1.8 error)