Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to support windows #164

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### 0.9.2 (Next)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put back the line, please.

* [#163](https://github.com/slack-ruby/slack-ruby-client/pull/164): Use `OpenSSL::X509::DEFAULT_CERT_DIR` and `OpenSSL::X509::DEFAULT_CERT_FILE` for default ca_cert and ca_file [@leifcr](https://github.com/leifcr)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this in the same format as everything else, needs a - before your name and a . at the end.

* [#161](https://github.com/slack-ruby/slack-ruby-client/pull/161): Added support for cursor pagination - [@dblock](https://github.com/dblock).
* Your contribution here.

Expand Down
9 changes: 7 additions & 2 deletions lib/slack/web/config.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
begin
require 'openssl'
rescue LoadError # rubocop:disable Lint/HandleExceptions
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a great place to put this, lib/slack-ruby-client.rb is better, it has all the require.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dblock Agree. Will move it there.


module Slack
module Web
module Config
Expand All @@ -21,8 +26,8 @@ module Config
def reset
self.endpoint = 'https://slack.com/api/'
self.user_agent = "Slack Ruby Client/#{Slack::VERSION}"
self.ca_path = `openssl version -a | grep OPENSSLDIR | awk '{print $2}'|sed -e 's/\"//g'`
self.ca_file = "#{ca_path}/ca-certificates.crt"
self.ca_path = defined?(OpenSSL) ? OpenSSL::X509::DEFAULT_CERT_DIR : nil
self.ca_file = defined?(OpenSSL) ? OpenSSL::X509::DEFAULT_CERT_FILE : nil
self.token = nil
self.proxy = nil
self.logger = nil
Expand Down
2 changes: 1 addition & 1 deletion lib/slack/web/faraday/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def connection

options[:headers]['User-Agent'] = user_agent if user_agent
options[:proxy] = proxy if proxy
options[:ssl] = { ca_path: ca_path, ca_file: ca_file }
options[:ssl] = { ca_path: ca_path, ca_file: ca_file } unless ca_path.nil? || ca_file.nil?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be tricky.

Do both options have to be specified? Can't just one do the trick? I think one certificate chain can work just fine as well as just the cert directory.

So this could be nicer as if ca_path || ca_file. Unless with || can be evil.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree. if ca_path || ca_file is better. And only one needs to be present.


request_options = {}
request_options[:timeout] = timeout if timeout
Expand Down