title: Ruby 1.8.7 and Net::HTTP: Making an SSL GET request with client cert?
body: <p>I'm trying to fetch a resource <em>via</em> SSL using <code>Net::HTTP</code>.  Here is the relevant code fragment:</p>
  
  <pre><code>req = Net::HTTP::Get.new(ContentURI.path)
  https = Net::HTTP.new(ContentURI.host, ContentURI.port)
  https.use_ssl = true
  https.cert = OpenSSL::X509::Certificate.new(@cert_raw)
  https.key = OpenSSL::PKey::RSA.new(@cert_key_raw)
  https.verify_mode = OpenSSL::SSL::VERIFY_PEER
  https.ca_file = File.join(TestDataPath, 'cacert.pem')
  resp = https.start { |cx| cx.request(req) }
  </code></pre>
  
  <p>or with the alternate last line:</p>
  
  <pre><code>resp = https.get(ContentURI.path)
  </code></pre>
  
  <p>I have verified that the various bits (cert, key, CA cert, <em>etc.</em>) are correct.</p>
  
  <p>The problem is that the <code>cx.request(req)</code> throws an exception:</p>
  
  <pre><code>OpenSSL::SSL::SSLError: SSL_connect SYSCALL returned=5 errno=0 state=SSLv3 read server session ticket A
  </code></pre>
  
  <p>The Apache SSL error log on the server contains the following:</p>
  
  <pre><code>[Tue Jan 24 11:47:26 2012] [debug] ssl_engine_kernel.c(1876): OpenSSL: Loop: SSLv3 read finished A
  [Tue Jan 24 11:47:26 2012] [debug] ssl_engine_kernel.c(1905): OpenSSL: Exit: error in SSLv3 write session ticket A
  [Tue Jan 24 11:47:26 2012] [debug] ssl_engine_kernel.c(1905): OpenSSL: Exit: error in SSLv3 write session ticket A
  [Tue Jan 24 11:47:26 2012] [info] [client 10.11.88.53] SSL handshake interrupted by system [Hint: Stop button pressed in browser?!]
  [Tue Jan 24 11:47:26 2012] [info] [client 10.11.88.53] Connection closed to child 0 with abortive shutdown (server _SERVERNAME_:443
  </code></pre>
  
  <p>The cert, key, and CA cert file work with this SSL host through other tools; I'm just having trouble reproducing that success programatically using <code>Net::HTTP[S]</code>.</p>
  
  <p>Thanks to anyone who can identify what I'm doing wrong!</p>