Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve "key not found: :ciphers"?

I'm very rusty with rails and I think a lot has changed in the 7-ish years since I've worked with it.

I'm trying to set up this sample app: https://iridakos.com/news/2015/06/21/rails-sample-api-ui

The problem I'm facing is that the UI doesn't interact with the API correctly. I get the error in the screenshot below.

The lofocats UI app gives me the following stack trace:

KeyError (key not found: :ciphers):
  lib/api/resource.rb:39:in `execute'
  app/models/cat_entry.rb:46:in `all'
  app/controllers/cat_entries_controller.rb:9:in `index'
  app/controllers/application_controller.rb:44:in `set_api_authentication_token'

line 44 in application_controler.rb is the first line of the begin block (Api::Configuration.current_authentication_token = session[:user_information][:authentication_token] if is_user_signed_in?):

def set_api_authentication_token
  begin
    Api::Configuration.current_authentication_token = session[:user_information][:authentication_token] if is_user_signed_in?
    yield
  ensure
    # Always nullify the token after each action.
    Api::Configuration.current_authentication_token = nil
  end
end

I'm not sure how to get around this error. I've not seen it before and searching SO gives some Cloudinary specific answers.

screenshot of error

like image 634
Ramy Avatar asked Apr 10 '19 15:04

Ramy


3 Answers

Upgrade your rest-client gem to >= 2.0.1.

This issue had to do with a newer version of OpenSSL and it was fixed in rest-client gem version 2.0.1, as per this Issue comment:

https://github.com/rest-client/rest-client/issues/612#issuecomment-313034465

So just make sure you are using 2.0.1 or greater of rest-client and you should be all good. We statically set ours to 2.1.0, which was the latest stable release at the time of writing, and everything is running smoothly.

like image 81
Joshua Pinter Avatar answered Sep 28 '22 09:09

Joshua Pinter


Just answering 9 years later as this was one of the only threads I found on this issue. In my case, using Unirest and RestClient both gave me the error in the title, despite my calls working from the command line with Curl. I switched to the HTTParty gem, and no more errors.

Inferring from a discussion on RestClient's Github, this may be because RestClient and Unirest "check for weak default TLS ciphers", due to older versions of Ruby not having a "sane cipher list".

https://github.com/rest-client/rest-client/pull/573

like image 40
Abe Avatar answered Sep 28 '22 07:09

Abe


How do you interact with API? Are you using some gem? I've got similar message error when i was using outdated rest-client gem. Updating from 1.X to 2.X solved issue.

NoMethodError (undefined method `response' for #<KeyError: key not found: :ciphers>)

Maybe some gem using outdated rest-client gem? This was my issue(if i recall correctly), i forked repo and updated dependency

like image 45
nuaky Avatar answered Sep 28 '22 08:09

nuaky