-
Notifications
You must be signed in to change notification settings - Fork 323
HTTPS
Tony Arcieri edited this page Dec 28, 2016
·
19 revisions
The HTTP gem supports HTTPS via Ruby's built-in OpenSSL module. Unlike certain other Ruby HTTP clients, all you have to do in order to use HTTPS is pass in an https://
-prefixed URL. That's it!
To use client certificates, you can pass in a custom OpenSSL::SSL::SSLContext
object containing the certificates you wish to use:
ctx = OpenSSL::SSL::SSLContext.new
ctx.cert = OpenSSL::X509::Certificate.new(File.read("client.crt"))
ctx.key = OpenSSL::PKey::RSA.new(File.read("client.key"))
HTTP.get("https://www.google.com", :ssl_context => ctx)