title: Unable to obtain peer certificate using HTTParty
body: <p>I am on a MacBook (macOS 10.14.3) with OpenSSL 1.1.1b (installed via Homebrew), ruby 2.6.0 (installed via rvm), and HTTParty 0.16.4 (installed via gem/bundler). According to <a href="https://github.com/jnunemaker/httparty/blob/master/examples/peer_cert.rb" rel="nofollow noreferrer">this example</a>, it should be possible to download a website's peer certificate. However, when I attempt this on my machine it fails:</p>
  
  <pre class="lang-rb prettyprint-override"><code>require "httparty"
  
  peer_cert = nil
  
  HTTParty.get("https://www.example.com") do |fragment|
    peer_cert ||= fragment.connection.peer_cert
  end
  
  p peer_cert
  </code></pre>
  
  <p>With the error</p>
  
  <pre><code>Traceback (most recent call last):
      28: from tmp/test.rb:5:in `&lt;main&gt;'
      27: from /Users/nicholas.chambers/.rvm/gems/ruby-2.6.0/gems/httparty-0.16.4/lib/httparty.rb:623:in `get'
      26: from /Users/nicholas.chambers/.rvm/gems/ruby-2.6.0/gems/httparty-0.16.4/lib/httparty.rb:491:in `get'
      25: from /Users/nicholas.chambers/.rvm/gems/ruby-2.6.0/gems/httparty-0.16.4/lib/httparty.rb:573:in `perform_request'
      24: from /Users/nicholas.chambers/.rvm/gems/ruby-2.6.0/gems/httparty-0.16.4/lib/httparty/request.rb:146:in `perform'
      23: from /Users/nicholas.chambers/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/net/http.rb:1470:in `request'
      22: from /Users/nicholas.chambers/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/net/http.rb:920:in `start'
      21: from /Users/nicholas.chambers/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/net/http.rb:1472:in `block in request'
      20: from /Users/nicholas.chambers/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/net/http.rb:1479:in `request'
      19: from /Users/nicholas.chambers/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/net/http.rb:1517:in `transport_request'
      18: from /Users/nicholas.chambers/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/net/http/response.rb:165:in `reading_body'
      17: from /Users/nicholas.chambers/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/net/http.rb:1518:in `block in transport_request'
      16: from /Users/nicholas.chambers/.rvm/gems/ruby-2.6.0/gems/httparty-0.16.4/lib/httparty/request.rb:150:in `block in perform'
      15: from /Users/nicholas.chambers/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/net/http/response.rb:204:in `read_body'
      14: from /Users/nicholas.chambers/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/net/http/response.rb:283:in `read_body_0'
      13: from /Users/nicholas.chambers/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/net/http/response.rb:264:in `inflater'
      12: from /Users/nicholas.chambers/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/net/http/response.rb:293:in `block in read_body_0'
      11: from /Users/nicholas.chambers/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/net/http/response.rb:405:in `read'
      10: from /Users/nicholas.chambers/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/net/protocol.rb:163:in `read'
       9: from /Users/nicholas.chambers/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/net/protocol.rb:488:in `&lt;&lt;'
       8: from /Users/nicholas.chambers/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/net/protocol.rb:497:in `call_block'
       7: from /Users/nicholas.chambers/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/net/http/response.rb:382:in `block in inflate_adapter'
       6: from /Users/nicholas.chambers/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/net/http/response.rb:382:in `inflate'
       5: from /Users/nicholas.chambers/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/net/http/response.rb:384:in `block (2 levels) in inflate_adapter'
       4: from /Users/nicholas.chambers/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/net/protocol.rb:488:in `&lt;&lt;'
       3: from /Users/nicholas.chambers/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/net/protocol.rb:497:in `call_block'
       2: from /Users/nicholas.chambers/.rvm/gems/ruby-2.6.0/gems/httparty-0.16.4/lib/httparty/request.rb:152:in `block (2 levels) in perform'
       1: from tmp/test.rb:6:in `block in &lt;main&gt;'
  /Users/nicholas.chambers/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/delegate.rb:87:in `method_missing': undefined method `connection' for #&lt;HTTParty::FragmentWithResponse:0x00007f9382035440&gt; (NoMethodError)
  </code></pre>
  
  <p>I've looked through open issues in the repository, and did some googling, but nothing came up. I'm currently at a loss. Any help would be appreciated, thank you!</p>
  
  <p>Update:
  Although I'd like to know why HTTParty doesn't work, <a href="https://stackoverflow.com/questions/34601260/using-ruby-openssl-to-download-and-read-certificates">this workaround</a> does it.</p>