Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Ruby (http://www.velocityreviews.com/forums/f66-ruby.html)
-   -   How To Turn Off Net::HTTP w/SSL Certificate Warnings? (http://www.velocityreviews.com/forums/t826875-how-to-turn-off-net-http-w-ssl-certificate-warnings.html)

Keith Fahlgren 12-12-2005 03:39 PM

How To Turn Off Net::HTTP w/SSL Certificate Warnings?
 
Hi,

I've got a little Ruby script that needs to use SSL but doesn't really
worry about authentication at all. Here's the relevant code:

https = Net::HTTP.new(URL, 443)
https.use_ssl = true
data = ""
https.start{|h|
h.get2(url) {|resp|
data = resp.body
}
}

When I run this, it works great but gives me (on STDERR):
peer certificate won't be verified in this SSL session

I don't really care about the verification, so how should I turn this
warning off or otherwise prevent it from printing?


Thanks,
Keith




ts 12-12-2005 04:02 PM

Re: How To Turn Off Net::HTTP w/SSL Certificate Warnings?
 
>>>>> "K" == Keith Fahlgren <keith@oreilly.com> writes:


Try

K> https = Net::HTTP.new(URL, 443)
K> https.use_ssl = true

https.verify_mode = OpenSSL::SSL::VERIFY_NONE

K> data = ""
K> https.start{|h|
K> h.get2(url) {|resp|
K> data = resp.body
K> }
K> }

Guy Decoux



Keith Fahlgren 12-12-2005 04:15 PM

Re: How To Turn Off Net::HTTP w/SSL Certificate Warnings?
 
On Monday 12 December 2005 11:02 am, ts wrote:
> =A0 =A0 =A0 =A0 =A0https.verify_mode =3D OpenSSL::SSL::VERIFY_NONE


Works great--can't believe that I didn't find it myself. That said, it=20
does provide a useful lesson for me: http://www.ruby-doc.org/stdlib/=20
doesn't mention private methods. So, for anyone in the future, look in=20
the private 'connect' method in net/http.rb in your local ruby library=20
for an explanation.=20

Thanks,
Keith



ts 12-12-2005 04:35 PM

Re: How To Turn Off Net::HTTP w/SSL Certificate Warnings?
 
>>>>> "K" == Keith Fahlgren <keith@oreilly.com> writes:

K> Works great--can't believe that I didn't find it myself. That said, it
K> does provide a useful lesson for me: http://www.ruby-doc.org/stdlib/
K> doesn't mention private methods.

It's just that the file https.rb is apparently not in www.ruby-doc.org

== class Net::HTTP

=== Instance Methods

[...]

: verify_mode, verify_mode=((|mode|))
Sets the flags for server the certification verification at
begining of SSL/TLS session.
OpenSSL::SSL::VERIFY_NONE or OpenSSL::SSL::VERIFY_PEER is acceptable.



Guy Decoux




All times are GMT. The time now is 02:55 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.