title: Connection reset by peer - SSL_connect when opening a URL
body: <p>I'm attempting to download a .zip file from a BingAds URL and am struggling to bypass this error: </p>
  
  <p><code>Connection reset by peer - SSL_connect</code></p>
  
  <p>I have this code currently running in production through another app but am utilizing nitrous.io for new application on a chromebook and running off their default rails install (the nitrous box).</p>
  
  <p>The code currently working in the other app:</p>
  
  <pre><code>class BingApi
    def self.get_data(request_params={})
      require 'zip'
  
      #Acquire Bing report download URL
      report_url = BingApi.acquire_report_url(report_request_id, request_params)
  
      zip_file = open(report_url)
  
      unzippedxml = Zip::File.open(zip_file)                      # open zip
      entry = unzippedxml.entries.reject(&amp;:directory?).first      # take first non-directory
      entry.get_input_stream{|is| is.read }          # read file contents
    end
  </code></pre>
  
  <p>The <code>report_url</code> will look something like: <a href="https://download.api.bingads.microsoft.com/ReportDownload/Download.aspx?q=cWmkJ72lVlzGEG%2fouLL8Xes2j6I5qVhLrnTqNIrW" rel="noreferrer">https://download.api.bingads.microsoft.com/ReportDownload/Download.aspx?q=cWmkJ72lVlzGEG%2fouLL8Xes2j6I5qVhLrnTqNIrW</a>....</p>
  
  <p>When visited, it will prompt the download of a .zip file which I unzip and then parse.</p>
  
  <p>However, this same code on the chromebook utilizing the nitrous box gives me the <code>Connection reset by peer - SSL_connect</code> error</p>
  
  <pre><code>Errno::ECONNRESET - Connection reset by peer - SSL_connect:                                                                                                                                                                                          
    /home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/net/http.rb:920:in `block in connect'                                                                                                                                                    
    /home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/timeout.rb:76:in `timeout'                                                                                                                                                               
    /home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/net/http.rb:920:in `connect'                                                                                                                                                             
    /home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/net/http.rb:863:in `do_start'                                                                                                                                                            
    /home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/net/http.rb:852:in `start'                                                                                                                                                               
    /home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/open-uri.rb:313:in `open_http'                                                                                                                                                           
    /home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/open-uri.rb:724:in `buffer_open'                                                                                                                                                         
    /home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/open-uri.rb:210:in `block in open_loop'                                                                                                                                                  
    /home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/open-uri.rb:208:in `open_loop'                                                                                                                                                           
    /home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/open-uri.rb:149:in `open_uri'                                                                                                                                                            
    /home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/open-uri.rb:704:in `open'                                                                                                                                                                
    /home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/open-uri.rb:34:in `open'                                                                                                                                                                 
    lib/bing_api.rb:25:in `get_data'                                                                                                                                                                                                                   
    lib/bing_api.rb:224:in `get_and_parse'   
  </code></pre>
  
  <p>I've been trying various different solutions:</p>
  
  <p><code>zip_file = open(report_url, :ssl_verify_mode =&gt; OpenSSL::SSL::VERIFY_NONE)</code></p>
  
  <p>OR</p>
  
  <p><code>zip_file = Faraday.get(report_url, :ssl =&gt; false)</code></p>
  
  <p>Finally I've bypassed it by using:</p>
  
  <pre><code>uri = URI.parse(report_url)
  https = Net::HTTP.new(uri.host, uri.port)
  https.open_timeout = 5
  https.use_ssl = true
  https.ssl_version = 'SSLv3'
  request = Net::HTTP::Get.new(uri.request_uri)
  zip_file = https.request(request)
  </code></pre>
  
  <p>but I can't pass the <code>zip_file</code> to <code>unzippedxml = Zip::File.open(zip_file)</code> or I get a <code>no implicit conversion of Net::HTTPOK into String</code> TypeError.</p>
  
  <p>Am I missing something simple here?  Should I do something different with that <code>zip_file.class =&gt; Net::HTTPOK</code> object?</p>
  
  <p>I tried calling <code>zip_file.body</code> but what is returned looks like what you'd see if you tried to open an zipped file in an editor prior to unzipping.</p>