Amitava Shee's Technical Diary

Sunday, September 03, 2006

HTTPS not suppored by open-uri module in Ruby

The open-uri module provides a convenient overload to Kernel::open that allows uniform and easy access to different IO resource type. However this does not work with SSL (https) sites. See the irb session below

irb(main):001:0> require 'open-uri'
=> true
irb(main):002:0> url = "https://www.salliemae.com/"
=> "https://www.salliemae.com/"
irb(main):003:0> open(url) { |f| p f.read }
OpenSSL::SSL::SSLError: certificate verify failed
from c:/ruby/lib/ruby/1.8/net/http.rb:586:in `connect'
from c:/ruby/lib/ruby/1.8/net/http.rb:586:in `connect'
from c:/ruby/lib/ruby/1.8/net/http.rb:553:in `do_start'
from c:/ruby/lib/ruby/1.8/net/http.rb:542:in `start'
from c:/ruby/lib/ruby/1.8/open-uri.rb:245:in `open_http'
from c:/ruby/lib/ruby/1.8/open-uri.rb:629:in `buffer_open'
from c:/ruby/lib/ruby/1.8/open-uri.rb:167:in `open_loop'
from c:/ruby/lib/ruby/1.8/open-uri.rb:165:in `open_loop'
from c:/ruby/lib/ruby/1.8/open-uri.rb:135:in `open_uri'
from c:/ruby/lib/ruby/1.8/open-uri.rb:531:in `open'
from c:/ruby/lib/ruby/1.8/open-uri.rb:86:in `open'
from (irb):3
irb(main):004:0>

0 Comments:

Post a Comment

<< Home