Forum: Ruby Certificates and Net::HTTP

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Peter Hickman (Guest)
on 2014-04-29 10:51
(Received via mailing list)
I am in the process of converting some Python code over to Ruby. The
runs in Python just fine and the Ruby code is almost working:

req = uri.path
req.body = "blah blah blah"

c = nil'config/certificates/client-2048.pem', 'rb') { |f| c =

res = Net::HTTP.start(, uri.port, :use_ssl => true) do |http|
  http.cert =
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
  http.ssl_version = :SSLv3
  http.request req

When this code is run is connects just fine res.code is '200' and the
service is returning JSON but it indicates that the certificate was not
being presented. In the Python code I have'https://...', data=payload,
'config/certificates/client-2048.key'), headers=headers)

I have the following file available client-2048.crt, client-2048.csr,
client-2048.key, client-2048.p12 and client-2048.pem and have tried
variation Google and StackOverflow shows me but without success.

Any pointers as to what I am doing wrong?
Mike Stok (Guest)
on 2014-04-29 14:16
(Received via mailing list)
On Apr 29, 2014, at 4:50 AM, Peter Hickman
<> wrote:

>   http.cert =
> Any pointers as to what I am doing wrong?

Hello Peter,

Forgive me if this doesn't answer your question directly, but have you
considered ? seems to suggest a way to
set up the SSL context the way you want.

Hope this helps,



Mike Stok <>

The "`Stok' disclaimers" apply.
This topic is locked and can not be replied to.