How to run "hello" example in Asana API documentation?
C:\Users\Desktop\ruby helloTask.rb
C:/Ruby193/lib/ruby/1.9.1/net/http.rb:799:in `connect': SSL_connect returned=1 e
rrno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL
::SSL::SSLError)
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:799:in `block in connect'
from C:/Ruby193/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
from C:/Ruby193/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:799:in `connect'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:755:in `do_start'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:744:in `start'
from helloTask.rb:38:in `<main>'
I tried to run the example mentioned in the Asana API documentation, errors are on the above. Where I went wrong?
(I work at Asana)
If you are using Ruby 1.9, there's a chance it's not properly finding the CA certs properly. If you are on Mac OS X, try (re)installing the curl-ca-bundle:
sudo port install curl-ca-bundle
You may also need to set http.ca_file in some cases. There's a more thorough writeup of this issue at http://martinottenwaelter.fr/2010/12/ruby19-and-the-ssl-error/
Disabling SSL verification would certainly work as well, though that's giving up a lot of the security that SSL provides since you can't be sure you're talking directly to Asana's servers.
I had the same problem after a google I had to change the line:
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
to
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
hope that helps
Related
I am new to rails and ruby. I am trying develop a rails 4 app with the YT gem to display and youtube videos. I see the following error when I access Title in rails App.
"A request to YouTube API caused an unexpected server error: {} You can retry the same request manually by running: curl -X GET -H "content-length: 0" -H "user-agent: Yt::Request (gzip)" "https://www.googleapis.com/youtube/v3/videos?id=bx5BUbiIXFw&key=AIzaSyCy7EGFIu9gFaWOlRGswoCugEi_20hB3js&part=snippet""
I could manually access the details with the URL given.
I tried from rails console it shows the following error.
Video.new url: "https://www.youtube.com/watch?v=bx5BUbiIXFw"
irb(main):006:0> video.title
Yt::Errors::ServerError: {"request_curl":"curl -X GET -H \"content-length: 0\" -
H \"user-agent: Yt::Request (gzip)\" \"https://www.googleapis.com/youtube/v3/vid
eos?id=bx5BUbiIXFw\u0026key=AIzaSyCpLai69UE3yYSRZKnFrwKkNJ6OIP2SfSI\u0026part=sn
ippet\"","response_body":"#\u003cOpenSSL::SSL::SSLError: SSL_connect returned=1
errno=0 state=SSLv3 read server certificate B: certificate verify failed\u003e"}
I have updated the SSL certificates for windows. Using Rails v 4.1.8, ruby 2.1.8p440 (2015-12-16 revision 53160) [i386-mingw32]. FYI I am able to upload files AWS with out any issues not sure if that helps with SSL.
Hoping to come out of this frustration.
SSLv3 read server certificate B: certificate verify failed
This may be a TLS vs SSL issue. Ruby may be attempting to connect with SSLv3. SSLv3 is insecure.
What happens when you run the above curl command with the --sslv3 option or when you execute the following code with and without the :TLSv1_2 set?
con = Net::HTTP.new(host, 443)
con.use_ssl = true
con.ssl_version = :TLSv1_2
con.get path { |r| ... }
I had a quick look at the YT gems docs and I don't see a way to set any SSL options.
https://github.com/google/google-api-ruby-client/issues/253
I had a similar issue and upgraded to Ruby 2.3.0 using rvm and it worked fine
rvm install 2.3.0
However, other people have mentioned that they have a workaround by updating their cert file. From dblommesteijn:
System wide solution would be this (for Yosemite and Ruby 2.2.1):
Downloading this http://curl.haxx.se/ca/cacert.pem, and saving it replacing /usr/local/etc/openssl/cert.pem.
Add export SSL_CERT_FILE=/usr/local/etc/openssl/cert.pem to your .bash_profile.
All net::http will pickup on ENV['SSL_CERT_FILE'].
RVM and ruby seems to have an outdated CA cert.
Been banging my head against this and need to bounce thoughts against someone else. I keep getting locally:
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=error: certificate verify failed
I get on heroku:
openssl::ssl::sslerror: ssl_connect returned=1 errno=0 state=sslv3 read server certificate b: certificate verify failed
My discourse instance has a SSL certificate from DNSimple, so that is all working perfectly. On heroku, since I just have a rails API, I opted not to get an SSL cert for that since heroku already provides you with one, and just use the URL from your heroku instance.
Now, I am able to use a Advanced Rest Client (Chrome extension) and make requests to my discourse instance no problem. Here is some code that I am using with the discourse_api gem.
discourse_client = DiscourseApi::Client.new('https://community.desta.co')
discourse_client.api_key = ENV['COMMUNITY_API_KEY']
# path to heroku cert, which I verified exists through `heroku run bash`
discourse_client.ssl(ca_file: '/usr/lib/ssl/certs/ca-certificates.crt')
discourse_client.api_username = 'system'
Maybe I'm misunderstanding certificates? Please help! Thanks
For anyone that may have this issue, I was able to fix it. I tested my SSL config at https://www.ssllabs.com/ssltest/analyze.html and realized I didn't have any intermediate certificates along with my primary certificate :(. Definitely overlooked that one, hope it helps anyone.
I have Rails API server hosted on Heroku, which makes an asynchronous POST request to a callback url specified in an initial API request by the client.
I have a problem when I try to POST to one of my clients' webapp over SSL.
connection = Faraday::Connection.new('https://subdomain.some_client.com', ssl: { ca_file: '/usr/lib/ssl/certs/ca-certificates.crt' })
connection.get '/test'
The following throws an error:
Faraday::Error::ConnectionFailed: SSL_connect returned=1 errno=0 state=error: certificate verify failed
However, if I post to another server over HTTPS, for example google, it works fine
connection = Faraday::Connection.new('https://www.google.com', ssl: { ca_file: '/usr/lib/ssl/certs/ca-certificates.crt' })
connection.get '/'
Does this mean the fault is on the client's SSL configuration? and if so, how can I assist them in debugging the problem?
UPDATE:
I can cURL POST to the client's webapp without problems, it's only when I do it through ruby's HTTP libraries it fails
Much appreciated
Thanks
My guess is that there is a problem with the SSL cert for your client's web app. Perhaps there is a certificate that is out of date or invalid. You could try this answer.
If you need to get around this (but probably not a good permanent solution, because of the potential security hole) you should be able to turn off the certificate verification by putting this before Bundler.require in your application.rb:
require 'openssl'
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
I am new to ruby and getting started to learn ruby on rails.
I am behind authenticated proxy network.
I researched on the internet, however the answers didn't work for me.
Password has special characters
I have exported http_proxy in ruby shell
export http_proxy=ht tp://foo:b\#r\#192.168.1.1:8080
When issued bundle update I get below error
:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/uri/generic.rb:213:in `initialize': the scheme http does not accept registry part: foo:b#r#192.168.1.1:8080 (or bad hostname?) (URI::InvalidURIError)
from c:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/uri/http.rb:84:in `initialize'
from c:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/uri/common.rb:214:in `new'
from c:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/uri/common.rb:214:in `parse'
I tried remove \ before 2 in both places, but didn't work.
I have put this content in .gemrc file in the folder where I create first_app
Yet didn't work.
Anyone who has used Rails behind authenticated proxy, please help me?
I'm new to Ruby and have created a site in Rails, I'm trying to run heroku create on my Windows machine and after generating a public key through git gui, I'm getting this error
Uploading ssh public key C:\Users\me/.ssh/id_rsa.pub
c:/ruby/lib/ruby/1.8/net/http.rb:590:in connect': unknown protocol (OpenSSL::SSL::SSLError)
from c:/ruby/lib/ruby/1.8/net/http.rb:590:inconnect'
from c:/ruby/lib/ruby/1.8/net/http.rb:557:in do_start'
from c:/ruby/lib/ruby/1.8/net/http.rb:546:instart'
from c:/ruby/lib/ruby/gems/1.8/gems/rest-client-1.4.2/lib/restclient/request.rb:150:in transmit
from c:/ruby/lib/ruby/gems/1.8/gems/rest-client-1.4.2/lib/restclient/request.rb:55:inexecute'
from c:/ruby/lib/ruby/gems/1.8/gems/rest-client-1.4.2/lib/restclient/request.rb:30:in execute'
from c:/ruby/lib/ruby/gems/1.8/gems/rest-client-1.4.2/lib/restclient/resource.rb:63:inpost'
from c:/ruby/lib/ruby/gems/1.8/gems/heroku-1.9.9/lib/heroku/client.rb:464:in send'
... 17 levels...
from c:/ruby/lib/ruby/gems/1.8/gems/heroku-1.9.9/lib/heroku/command.rb:20:inrun'
from c:/ruby/lib/ruby/gems/1.8/gems/heroku-1.9.9/bin/heroku:13
from c:/ruby/bin/heroku:19:in `load'
from c:/ruby/bin/heroku:19
Is there something I need to set up for SSL?
Thanks for any help in advance.
I'd try reinstalling Ruby using something like http://rubyinstaller.org/