RestClient failing to GET resource using SSL client certificate

Hi All,

I’m trying to use RestClient to retrieve a page that’s secured using an
SSL client certificate. My code is as follows:

require ‘restclient’

p12 = OpenSSL::PKCS12.new(File.read(‘client.p12’), ‘password’)
client = RestClient::Resource.new(‘https://example.com/’,
:ssl_client_key => p12.key,
:verify_ssl => OpenSSL::SSL::VERIFY_NONE)
client.get

When I run it, I see the following failure:

1.9.3-p374 :007 > client.get
RestClient::BadRequest: 400 Bad Request

I’m fairly sure this is a failure to authenticate, as I get the same
error in a browser if I don’t install the client certificate.

I’m using OpenSSL::SSL::VERIFY_NONE because the server has a
self-signed certificate, and I believe this is the correct value to pass
to ignore that.

Any suggestions on how to get this working would be greatly appreciated

  • even a pointer to some detailed documentation, or a suggestion of a
    different Gem could work. I’ve not had much luck with either the Gem
    docs or Google :frowning:

TIA for any advice …

Yours,
Duncan B.

Also having issues with SSL through Ruby net libraries. I can suggest
logging the RestClient activity, which has been helpful to me at least.

I use: RestClient.log = STDERR

as explained here: GitHub - rest-client/rest-client: Simple HTTP and REST client for Ruby, inspired by microframework syntax for specifying actions.