rubyubuntucurb

SSL peer certificate or SSH remote key was not OK (Curl::Err::SSLPeerCertificateError)


I got the error on ubuntu but works on mac

But if I run the curl command on ubuntu , it works. is curb a buggy gem?

2.1.0/gems/curb-0.8.6/lib/curl/easy.rb:72:in `perform': SSL peer certificate or SSH remote key was not OK (Curl::Err::SSLPeerCertificateError)

RUBY

resp = Curl::Easy.http_post(server_url, content_to_send) do |curl|
  curl.ssl_verify_peer = false
  curl.headers = header.clone
end

Detail

/home/poc/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/curb-0.8.6/lib/curl/easy.rb:72:in `perform': SSL peer certificate or SSH remote key was not OK (Curl::Err::SSLPeerCertificateError)
    from /home/poc/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/curb-0.8.6/lib/curl/easy.rb:398:in `http_post'
    from /home/poc/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/curb-0.8.6/lib/curl/easy.rb:398:in `http_post'
    from curb.rb:12:in `curl_query'
    from curb.rb:21:in `<main>'

Solution

  • I had the same error, turns out for linux machines you need ssl_verify_host=0

    To be safe I use both:

    resp = Curl::Easy.http_post(server_url, content_to_send) do |curl|
      curl.ssl_verify_peer = false
      curl.ssl_verify_host = 0
      curl.headers = header.clone
    end
    

    Also a heads up—you might be developing on mac, but deploying to a server running linux, so better to use both even on a mac.