Francois Beausoleil
2006-Mar-24 17:09 UTC
[Rails] [OT] Does Net::HTTP support secure connections ?
Hi ! I''m trying to connect to an https URL, but it seems it doesn''t work. Has anyone successfully connected from Ruby to an HTTPS server ? Thanks ! -- Fran?ois Beausoleil http://blog.teksol.info/
Brian Hogan
2006-Mar-24 17:19 UTC
[Rails] [OT] Does Net::HTTP support secure connections ?
yes it does.
require ''net/http''
require ''net/https''
h = Net::HTTP.new("www.google.com", 443)
h.use_ssl = true
resp, data = h.get("/", nil )
@message = resp.message
resp.code
Hope that helps.
On 3/24/06, Francois Beausoleil <francois.beausoleil@gmail.com>
wrote:>
> Hi !
>
> I''m trying to connect to an https URL, but it seems it
doesn''t work.
> Has anyone successfully connected from Ruby to an HTTPS server ?
>
> Thanks !
> --
> Fran?ois Beausoleil
> http://blog.teksol.info/
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060324/58f30d53/attachment.html
Francois Beausoleil
2006-Mar-24 19:17 UTC
[Rails] [OT] Does Net::HTTP support secure connections ?
Hello Brian ! 2006/3/24, Brian Hogan <bphogan@gmail.com>:> require ''net/http'' > require ''net/https'' > > h = Net::HTTP.new("www.google.com", 443) > h.use_ssl = true > resp, data = h.get("/", nil ) > @message = resp.message > resp.codeWorks like a charm. Thanks ! -- Fran?ois Beausoleil http://blog.teksol.info/
Justin Bailey
2006-Mar-24 21:13 UTC
[Rails] [OT] Does Net::HTTP support secure connections ?
A bit off topic, but why use Net::HTTP if you don''t have to. open-uri
(in
the standard library) is SOOOO much simpler:
require ''open-uri''
open("https://www.google.com") do |f|
@message = f.gets(nil)
f.status # array of messages but same effect
end
On 3/24/06, Francois Beausoleil <francois.beausoleil@gmail.com>
wrote:>
> Hello Brian !
>
> 2006/3/24, Brian Hogan <bphogan@gmail.com>:
> > require ''net/http''
> > require ''net/https''
> >
> > h = Net::HTTP.new("www.google.com", 443)
> > h.use_ssl = true
> > resp, data = h.get("/", nil )
> > @message = resp.message
> > resp.code
>
> Works like a charm. Thanks !
> --
> Fran?ois Beausoleil
> http://blog.teksol.info/
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060324/a5f537ce/attachment.html
Brian Hogan
2006-Mar-24 21:26 UTC
[Rails] [OT] Does Net::HTTP support secure connections ?
Well, let''s see...
irb(main):030:0> require ''open-uri''
=> false
irb(main):031:0>
irb(main):032:0* open("https://www.google.com") do |f|
irb(main):033:1* @message = f.gets(nil)
irb(main):034:1> f.status # array of messages but same effect
irb(main):035:1> end
OpenSSL::SSL::SSLError: certificate verify failed
from c:/ruby/lib/ruby/1.8/net/http.rb:588:in `connect''
from c:/ruby/lib/ruby/1.8/net/http.rb:588:in `connect''
from c:/ruby/lib/ruby/1.8/net/http.rb:555:in `do_start''
from c:/ruby/lib/ruby/1.8/net/http.rb:544: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):32
That''s why I don''t use it! :)
Seriously, net/https warns of certificate issues but does not throw
exceptions. Not every site has valid certificates and so I tend to always go
the somewhat longer route.
On 3/24/06, Justin Bailey <jgbailey@gmail.com>
wrote:>
> A bit off topic, but why use Net::HTTP if you don''t have to.
open-uri (in
> the standard library) is SOOOO much simpler:
>
> require ''open-uri''
>
> open("https://www.google.com ") do |f|
> @message = f.gets(nil)
> f.status # array of messages but same effect
> end
>
>
> On 3/24/06, Francois Beausoleil < francois.beausoleil@gmail.com>
wrote:
>
> > Hello Brian !
>
> 2006/3/24, Brian Hogan < bphogan@gmail.com>:
> > require ''net/http''
> > require ''net/https''
> >
> > h = Net::HTTP.new("www.google.com", 443)
> > h.use_ssl = true
> > resp, data = h.get("/", nil )
> > @message = resp.message
> > resp.code
>
> Works like a charm. Thanks !
> --
> Fran?ois Beausoleil
> http://blog.teksol.info/
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
>
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060324/4472c7e5/attachment.html
Justin Bailey
2006-Mar-24 21:34 UTC
[Rails] [OT] Does Net::HTTP support secure connections ?
Good point, good point. I probably would have seen that if OpenSSL actually worked on Windows w/ 1.8.4 (or at least, with my one-click installer''s version of 1.8.4). On 3/24/06, Brian Hogan <bphogan@gmail.com> wrote:> > Well, let''s see... > > irb(main):030:0> require ''open-uri'' > => false > irb(main):031:0> > irb(main):032:0* open("https://www.google.com") do |f| > irb(main):033:1* @message = f.gets(nil) > irb(main):034:1> f.status # array of messages but same effect > irb(main):035:1> end > OpenSSL::SSL::SSLError: certificate verify failed > from c:/ruby/lib/ruby/1.8/net/http.rb:588:in `connect'' > from c:/ruby/lib/ruby/1.8/net/http.rb:588:in `connect'' > from c:/ruby/lib/ruby/1.8/net/http.rb:555:in `do_start'' > from c:/ruby/lib/ruby/1.8/net/http.rb:544: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):32 > > That''s why I don''t use it! :) > > Seriously, net/https warns of certificate issues but does not throw > exceptions. Not every site has valid certificates and so I tend to always go > the somewhat longer route. > > > > > > > On 3/24/06, Justin Bailey <jgbailey@gmail.com> wrote: > > > > A bit off topic, but why use Net::HTTP if you don''t have to. open-uri > > (in the standard library) is SOOOO much simpler: > > > > require ''open-uri'' > > > > open(" https://www.google.com ") do |f| > > @message = f.gets(nil) > > f.status # array of messages but same effect > > end > > > > > > On 3/24/06, Francois Beausoleil < francois.beausoleil@gmail.com> wrote: > > > > > Hello Brian ! > > > > 2006/3/24, Brian Hogan < bphogan@gmail.com>: > > > require ''net/http'' > > > require ''net/https'' > > > > > > h = Net:: HTTP.new("www.google.com", 443) > > > h.use_ssl = true > > > resp, data = h.get("/", nil ) > > > @message = resp.message > > > resp.code > > > > Works like a charm. Thanks ! > > -- > > Fran?ois Beausoleil > > http://blog.teksol.info/ > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060324/aaa189a1/attachment.html
Tanner Burson
2006-Mar-24 22:44 UTC
[Rails] [OT] Does Net::HTTP support secure connections ?
On 3/24/06, Justin Bailey <jgbailey@gmail.com> wrote:> > Good point, good point. I probably would have seen that if OpenSSL > actually worked on Windows w/ 1.8.4 (or at least, with my one-click > installer''s version of 1.8.4). >Have you submitted this as a bug to the instant rails team? The project site can be found at http://rubyforge.org/projects/instantrails . I''d highly suggest you submit any problems like this that you run into so that the team can get them fixed for the next release. -- ===Tanner Burson==tanner.burson@gmail.com http://tannerburson.com <---Might even work one day... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060324/5aa4d1ac/attachment.html
Justin Bailey
2006-Mar-24 23:23 UTC
[Rails] [OT] Does Net::HTTP support secure connections ?
Done (its actually the one-click installer). Thanks for the reminder. On 3/24/06, Tanner Burson <tanner.burson@gmail.com> wrote:> > > > On 3/24/06, Justin Bailey <jgbailey@gmail.com> wrote: > > > Good point, good point. I probably would have seen that if OpenSSL > > actually worked on Windows w/ 1.8.4 (or at least, with my one-click > > installer''s version of 1.8.4). > > > > > Have you submitted this as a bug to the instant rails team? The project > site can be found at http://rubyforge.org/projects/instantrails . I''d > highly suggest you submit any problems like this that you run into so that > the team can get them fixed for the next release. > > > -- > ===Tanner Burson==> tanner.burson@gmail.com > http://tannerburson.com <---Might even work one day... > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060324/ebc71393/attachment.html
When I try it I get:
ArgumentError: open-uri doesn''t support https.
from c:/ruby/lib/ruby/1.8/open-uri.rb:583:in `proxy_open''
from c:/ruby/lib/ruby/1.8/open-uri.rb:525:in `direct_open''
from c:/ruby/lib/ruby/1.8/open-uri.rb:169:in `open_loop''
from c:/ruby/lib/ruby/1.8/open-uri.rb:164:in `catch''
from c:/ruby/lib/ruby/1.8/open-uri.rb:164:in `open_loop''
from c:/ruby/lib/ruby/1.8/open-uri.rb:134:in `open_uri''
from c:/ruby/lib/ruby/1.8/open-uri.rb:424:in `open''
from c:/ruby/lib/ruby/1.8/open-uri.rb:85:in `open''
from (irb):10
But Net::HTTP worked fine.
b
(windoze w/ ruby 1.8.2 (2004-12-25) [i386-mswin32])
Brian Hogan wrote:> Well, let''s see...
>
> irb(main):030:0> require ''open-uri''
> => false
> irb(main):031:0>
> irb(main):032:0* open("https://www.google.com") do |f|
> irb(main):033:1* @message = f.gets(nil)
> irb(main):034:1> f.status # array of messages but same effect
> irb(main):035:1> end
> OpenSSL::SSL::SSLError: certificate verify failed
> from c:/ruby/lib/ruby/1.8/net/http.rb:588:in `connect''
> from c:/ruby/lib/ruby/1.8/net/http.rb:588:in `connect''
> from c:/ruby/lib/ruby/1.8/net/http.rb:555:in `do_start''
> from c:/ruby/lib/ruby/1.8/net/http.rb:544: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):32
>
> That''s why I don''t use it! :)
>
> Seriously, net/https warns of certificate issues but does not throw
> exceptions. Not every site has valid certificates and so I tend to
> always go the somewhat longer route.
>
>
>
>
>
> On 3/24/06, *Justin Bailey* <jgbailey@gmail.com
> <mailto:jgbailey@gmail.com>> wrote:
>
> A bit off topic, but why use Net::HTTP if you don''t have to.
> open-uri (in the standard library) is SOOOO much simpler:
>
> require ''open-uri''
>
> open(" https://www.google.com ") do |f|
> @message = f.gets(nil)
> f.status # array of messages but same effect
> end
>
>
> On 3/24/06, * Francois Beausoleil* < francois.beausoleil@gmail.com
> <mailto:francois.beausoleil@gmail.com>> wrote:
>
> Hello Brian !
>
> 2006/3/24, Brian Hogan < bphogan@gmail.com
<mailto:bphogan@gmail.com>>:
>> require ''net/http''
>> require ''net/https''
>>
>> h = Net:: HTTP.new("www.google.com
> <http://www.google.com>", 443)
>> h.use_ssl = true
>> resp, data = h.get("/", nil )
>> @message = resp.message
>> resp.code
>
> Works like a charm. Thanks !
> --
> Fran?ois Beausoleil
> http://blog.teksol.info/
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org <mailto:Rails@lists.rubyonrails.org>
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
>
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org <mailto:Rails@lists.rubyonrails.org>
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails