Is there something that already works?
I believe the HTTP client library Faraday is focus of more Ruby community action is these days.
It comes with a :net_http_persistent
adapter, which supports SSL client certificates. You can probably do something like this:
ssl_options = {
cert: OpenSSL::X509::Certificate.new(File.read('./certificate/client-2048.pem')),
key: OpenSSL::PKey::RSA.new(File.read('./certificate/client-2048.key'), 'mypassword')
}
conn = Faraday.new(url: 'https://example.com', ssl: ssl_options) do |faraday|
faraday.adapter = Faraday::Adapter::NetHttpPersistent
end
conn.get '/my-resource'
HTTParty
According to the specs:
... the resulting connection when providing PEM certificates when scheme is https
- uses the provided PEM certificate
- will verify the certificate
You can use the pem
classmethod to provide a client certificate in PEM format.
REST Client
It's not as dead as all that -- Larry Gilbert (@L2G
) is still merging in pull requests and keeping the lights on. He's nodded his general approval in the issue tracker. I suspect it's just not at the top of his priority queue at the moment.
The guy who sent in that pull request, @byroot
, has been keeping his code up to date so you shouldn't need to do much at all while you wait.