Project

General

Profile

Bug #14848 ยป verify_callback.rb

aeris (Nicolas Vinot), 06/15/2018 10:00 AM

 
#!/usr/bin/env ruby
require 'net/https'

def get(verify=true, host='imirhil.fr', port=443)
http = Net::HTTP.new 'imirhil.fr', 443
http.use_ssl = true
http.verify_callback = lambda { |_, _| false }
http.verify_mode = verify ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
http.get '/'
end

get false # => #<Net::HTTPOK:0x00007f0ee173a040>
get true # => OpenSSL::SSL::SSLError
    (1-1/1)