If the core network / https is used, then this is pretty simple:
require 'net/https'
require 'uri'
uri = URI.parse(ARGV[0] || 'https://localhost/')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true if uri.scheme == "https"
http.key = pkey
http.cert= cert
http.start {
http.request_get(uri.path) {|res|
print res.body
}
}
If you combined them, you will have to massage them using some methods of the openssl utility.
For a custom http client, you should read the docs for the ruby openssl library for gory details.
But in short, something like this should work:
ctx = OpenSSL::SSL::SSLContext.new
ctx.key = private_key_file
ctx.cert = certificate_file
.. and then specify the context for your connection.
Roman source
share