# problem opening https OpenSSL problem

**URL:** <https://discuss.rubyonrails.org/t/problem-opening-https-openssl-problem/62444>\
**Category:** rubyonrails-talk\
**Created:** [January 22, 2012, 7:02pm UTC](https://discuss.rubyonrails.org/t/problem-opening-https-openssl-problem/62444 "2012-01-22T19:02:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [January 22, 2012, 7:02pm UTC](https://discuss.rubyonrails.org/t/problem-opening-https-openssl-problem/62444/1 "2012-01-22T19:02:07Z")

</div>

I'm having trouble using the open(url) method.

This used to work fine, but I've recently updated gems, and it seems to have broken. Also, I've switched to running on ree-1.8.7 to try and mimic my heroku stack. Not sure if that might have something to do with it as well

at the top of my class I require:

&nbsp;&nbsp;require 'date' &nbsp;&nbsp;require 'nokogiri' &nbsp;&nbsp;require 'open-uri'

The code that is breaking it is:

puts(encoded\_url) &nbsp;&nbsp;puts"trying to open doc" &nbsp;&nbsp;doc = open(encoded\_url, "UserAgent" =\> "Ruby-OpenURI").read &nbsp;&nbsp;puts"just opened doc" &nbsp;&nbsp;return parsed\_doc = Nokogiri::XML(doc)

the log out put is :

[https://maps.googleapis.com/maps/api/place/search/xml?location=51.522416,-0.131836&radius=50000&types=bar|night\_club|stadium|movie\_theater&name=Hotel%20Suite%20Inn%20Pennsylvania&sensor=false&key=xxxxx](https://maps.googleapis.com/maps/api/place/search/xml?location=51.522416,-0.131836&radius=50000&types=bar%7Cnight_club%7Cstadium%7Cmovie_theater&name=Hotel%20Suite%20Inn%20Pennsylvania&sensor=false&key=xxxxx)(real key here) trying to open doc [Worker(host:Michael-Bs-MacBook-Pro.local pid:41513)] Admin::Events::ScraperManager failed with OpenSSL::SSL::SSLError: SSL\_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed - 1 failed attempts

/////

As you can see, it never gets to the line "just opened doc", so it is failing on

doc = open(encoded\_url, "UserAgent" =\> "Ruby-OpenURI").read

Having googled around, I found a fix for OpenSSL, which involved creating certificates, and setting them like this

https.ca\_file = '/opt/local/share/curl/curl-ca-bundle.crt'

but I don't have an https object, so how can I set these certificates!

Any help appreciated

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [January 23, 2012, 4:45am UTC](https://discuss.rubyonrails.org/t/problem-opening-https-openssl-problem/62444/2 "2012-01-23T04:45:41Z")

</div>

require 'net/http'

def http\_connection

&nbsp;&nbsp;@http\_connection = Net::HTTP.start(host, port) &nbsp;&nbsp;@http\_connection.post(uri\_path, params) &nbsp;&nbsp;@http\_connection.finish &nbsp;&nbsp;@http\_connection = nil

end

I hope it is work

Try this way

Bye:) bdeveloper01
