mixpanel / mixpanel-ruby

Other
172 stars 72 forks source link

read server certificate B: certificate verify failed #83

Open acolchagoff opened 9 years ago

acolchagoff commented 9 years ago

I'm trying to add Mixpanel to our back end and do a call to the people.set endpoint.

My call looks like this:

    res = @tracker.people.set(
        user.id, {
            '$first_name'       => user.first_name,
            '$last_name'        => user.last_name,
            '$email'            => user.email,
            '$phone'            => user.phone,
            '$created'          => user.created_at
        })
    res

In all my testing, res is simply 'false'

I used my debugger to dig into the gem a little bit and I'm finding that there is a connection error exception thrown on line 100 of consumer.rb:

"SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed"

I don't have any trouble making calls to the mixpanel api using javascript, so I think my machine is configured fine, also this is my local machine so my server will have a different environment.

ddgromit commented 9 years ago

+1 I get the same issue locally, though it works on heroku.

I've run rvm osx-ssl-certs update all and my certs are up to date.

ddgromit commented 9 years ago

@denodster figured it out, its a problem with your openssl configuration, not mixpanel specifically.

To see the problem, try this code with any https url as the endpoint, e.g. https://www.google.com, and it'll return a certificate error:

require 'net/https'
endpoint = 'https://api.mixpanel.com'
uri = URI(endpoint)
request = Net::HTTP::Get.new(uri.request_uri)

client = Net::HTTP.new(uri.host, uri.port)
client.use_ssl = true
client.open_timeout = 2
client.continue_timeout = 10
client.read_timeout = 10
client.ssl_timeout = 2

response = client.request(request)
puts response.code
puts response.body

This doc explains a few ways to fix it. Force linking openssl might work but might cause problems. So I ran the following which updates apple's version of openssl that is installed by default, and it all just worked.

brew tap raggi/ale
brew install openssl-osx-ca
openssl-osx-ca
acolchagoff commented 9 years ago

Yeah I can confirm that this is sorted out. Thanks all.

zyskowsk commented 9 years ago

Thanks for pointing this out @denodster, and thanks for investigating @ddgromit!

alexch commented 9 years ago

to improve the Google Fu of this (closed but still relevant) issue, I'll post my full error message:

#<Mixpanel::ConnectionError: Could not connect to Mixpanel, with error "SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed".>

@ddgromit's 3-line solution worked for me. Remember to spring stop if you're using Spring!

vincentroyc commented 9 years ago

I still have this issue. Tried everything in this thread. I also tried @ddgromit sample code with another https url to see and it did not return an error. But with mixpanel https url i get the error. My certs are up to date.

Anyone have an idea?

tombroomfield commented 9 years ago

Also have this issue, tried @ddgromit and nothing doing. It seems to be only recent for me.

stuartchaney commented 9 years ago

+1

davebcn87 commented 9 years ago

I also have this problem... 😭

zyskowsk commented 9 years ago

Sorry for the silence everyone, I am looking into this I have not been able to reproduce. In the meantime can you let me know how you are using the ruby gem in your stack so that I can try to repro?

acolchagoff commented 9 years ago

Even if this is not a bug in the gem, It might be helpful if the return was something other than just 'false' when a failure occurs.

holamendi commented 8 years ago

I also have this issue, tried all the workarounds and still nothing.

avk commented 8 years ago

+1

avk commented 8 years ago

This is one way of turning things off locally:

# config/initializers/mixpanel.rb
if Rails.env.development? 
  # silence local SSL errors
  Mixpanel.config_http do |http|
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  end
end
ilan-senexx commented 8 years ago

@avk +1

dabobert commented 8 years ago

i have the same issue. i'm using @avk 's patch for the time being

jonathansimmons commented 8 years ago

@avk's patch does work but is there an official fix for this in the works?

yonibot commented 8 years ago

+1 struggling with this for ages

michaelklem commented 8 years ago

+1

Thank you @avk for the work around.

sevenshadow commented 8 years ago

Another thanks to @avk for the workaround.

erinpettigrew commented 8 years ago

Thanks @avk! Fixed.

knagode commented 8 years ago

+1 struggling with this for ages

jmtame commented 7 years ago

thanks @ddgromit