Skip to content

Instantly share code, notes, and snippets.

@mikehale
Created April 19, 2013 19:01
Show Gist options
  • Select an option

  • Save mikehale/5422432 to your computer and use it in GitHub Desktop.

Select an option

Save mikehale/5422432 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'net/https'
https = Net::HTTP.new('logplex.herokai.com', 443)
https.use_ssl = true
https.verify_mode = OpenSSL::SSL::VERIFY_PEER
# use system defaults
https.cert_store = OpenSSL::X509::Store.new
https.cert_store.set_default_paths
https.verify_callback = lambda do |preverify_ok, ssl_context|
# p [preverify_ok, ssl_context, ssl_context.error, ssl_context.error_string]
# puts caller
# puts
if (!preverify_ok) || ssl_context.error != 0
puts "SSL Verification failed -- Preverify: #{preverify_ok}, Error: #{ssl_context.error_string} (#{ssl_context.error})"
end
true
end
p https.request_get('/')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment