mixpanel-ruby icon indicating copy to clipboard operation
mixpanel-ruby copied to clipboard

read server certificate B: certificate verify failed

Open acolchagoff opened this issue 9 years ago • 23 comments

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.

acolchagoff avatar Jun 18 '15 13:06 acolchagoff

+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 avatar Jun 19 '15 22:06 ddgromit

@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

ddgromit avatar Jun 19 '15 23:06 ddgromit

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

acolchagoff avatar Jun 22 '15 13:06 acolchagoff

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

zyskowsk avatar Jun 22 '15 16:06 zyskowsk

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!

alexch avatar Jul 07 '15 00:07 alexch

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?

vincentroyc avatar Aug 05 '15 14:08 vincentroyc

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

tombroomfield avatar Aug 25 '15 01:08 tombroomfield

+1

stuartchaney avatar Aug 29 '15 17:08 stuartchaney

I also have this problem... 😭

davebcn87 avatar Sep 02 '15 13:09 davebcn87

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?

zyskowsk avatar Sep 03 '15 22:09 zyskowsk

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.

acolchagoff avatar Sep 08 '15 15:09 acolchagoff

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

holamendi avatar Oct 09 '15 12:10 holamendi

+1

avk avatar Oct 22 '15 02:10 avk

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

avk avatar Oct 22 '15 02:10 avk

@avk +1

ilan-senexx avatar Nov 01 '15 07:11 ilan-senexx

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

dabobert avatar Nov 19 '15 21:11 dabobert

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

jonathansimmons avatar Jan 19 '16 20:01 jonathansimmons

+1 struggling with this for ages

yonibot avatar Jan 27 '16 13:01 yonibot

+1

Thank you @avk for the work around.

michaelklem avatar Mar 04 '16 00:03 michaelklem

Another thanks to @avk for the workaround.

sevenshadow avatar Mar 09 '16 12:03 sevenshadow

Thanks @avk! Fixed.

erinpettigrew avatar Mar 15 '16 00:03 erinpettigrew

+1 struggling with this for ages

knagode avatar Sep 19 '16 15:09 knagode

thanks @ddgromit

jmtame avatar Dec 29 '16 20:12 jmtame