donp@portland-1:/tmp$ cat ssl.rb
require 'net/https'
url = URI.parse 'https://www.wamu.com'
server = Net::HTTP.new url.host, url.port
server.use_ssl = url.scheme == 'https'
server.verify_mode = OpenSSL::SSL::VERIFY_NONE
response = server.get url.request_uri
puts response.code
donp@portland-1:/tmp$ ruby ssl.rb
/usr/lib/ruby/1.8/net/http.rb:565:in `connect': undefined method `verify_mode' for nil:NilClass (NoMethodError)
from /usr/lib/ruby/1.8/net/http.rb:555:in `do_start'
from /usr/lib/ruby/1.8/net/http.rb:544:in `start'
from /usr/lib/ruby/1.8/net/http.rb:1031:in `request'
from /usr/lib/ruby/1.8/net/http.rb:771:in `get'
from ssl.rb:7
donp@portland-1:/tmp$
564 if use_ssl?
565 unless @ssl_context.verify_mode
566 warn "warning: peer certificate won't be verified in this SSL session"
567 @ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
568 end
it looks like the code is there to set @ssl_context in net/protocols.rb
36 def initialize(addr, port, otime = nil, rtime = nil, dout = nil)
37 super
38 @ssl_context = OpenSSL::SSL::SSLContext.new()
39 end
but for some reason this modified initialize is not being run.
im thinking it has something to do with the order of 'require' statements.