slack-ruby / slack-ruby-client

A Ruby and command-line client for the Slack Web, Real Time Messaging and Event APIs.
MIT License
1.19k stars 213 forks source link

Faraday::SSLError: SSL_connect returned=1 errno=0 state=error: certificate verify failed #477

Open hopewise opened 1 year ago

hopewise commented 1 year ago

I am initializing my client as:

client = Slack::Web::Client.new(ca_path: "/home/deploy", ca_file: "cacert.pem")

where cacert.pem was downloaded from Mozilla here https://curl.se/docs/caextract.html

but I am still getting error:

client.chat_postMessage(channel:  @channel, text: "TEST", as_user: true)
Faraday::SSLError: SSL_connect returned=1 errno=0 state=error: certificate verify failed

Any idea? Kindly notice that certificate worked well with the slack-notifier gem which calls hooks.slack.com

dblock commented 1 year ago

I would first check whether https://github.com/slack-ruby/slack-ruby-client/blob/master/lib/slack/web/faraday/connection.rb#L17 is getting these options, just to be sure. Then reproduce just with Faraday directly.

eftikharEmad commented 1 year ago

@dblock I checked that and I can see the params I passed on this line https://github.com/slack-ruby/slack-ruby-client/blob/master/lib/slack/web/faraday/connection.rb#LL18C1-L18C1

Screen Shot 2023-06-05 at 5 32 46 PM

still get same error Faraday::SSLError: SSL_connect returned=1 errno=0 state=error: certificate verify faile

dblock commented 1 year ago

Reproduce with Faraday alone. I suspect it's the same problem, which means it's not an issue with the client itself (I don't know what the problem is though).

gabifija commented 2 weeks ago

I had the same error. As a fix, I passed params ca_path and ca_file directly: Slack::Web::Client.new ca_path: nil, ca_file: nil . It should be save since it uses default cert store if the params are empty. https://github.com/jruby/jruby-openssl/blob/968bff99a394cb53ab8388316c03c41f4e231015/lib/openssl/ssl.rb#L138

dblock commented 2 weeks ago

@gabifija In slack-ruby-client 2.0 these were set to nil, see https://github.com/slack-ruby/slack-ruby-client/blob/master/UPGRADING.md#upgrading-to--200. Your issue is different, the OP is setting these to specific values.