diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4e995552..b4c944dd 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,12 +1,12 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2017-04-30 12:02:22 -0400 using RuboCop version 0.35.0. +# on 2017-09-13 09:10:02 +0200 using RuboCop version 0.35.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 3 +# Offense count: 4 Lint/HandleExceptions: Exclude: - 'lib/slack-ruby-client.rb' @@ -20,7 +20,7 @@ Lint/UnusedBlockArgument: Exclude: - 'lib/slack/messages/formatting.rb' -# Offense count: 14 +# Offense count: 15 Metrics/AbcSize: Max: 44 @@ -29,25 +29,25 @@ Metrics/AbcSize: Metrics/ClassLength: Max: 165 -# Offense count: 3 +# Offense count: 4 Metrics/CyclomaticComplexity: Max: 9 -# Offense count: 720 +# Offense count: 615 # Configuration parameters: AllowURI, URISchemes. Metrics/LineLength: - Max: 288 + Max: 266 # Offense count: 7 # Configuration parameters: CountComments. Metrics/MethodLength: Max: 32 -# Offense count: 2 +# Offense count: 3 Metrics/PerceivedComplexity: Max: 11 -# Offense count: 59 +# Offense count: 63 # Configuration parameters: Exclude. Style/Documentation: Enabled: false @@ -58,12 +58,12 @@ Style/FileName: Exclude: - 'lib/slack-ruby-client.rb' -# Offense count: 116 +# Offense count: 120 # Configuration parameters: AllowedVariables. Style/GlobalVars: Enabled: false -# Offense count: 21 +# Offense count: 22 # Configuration parameters: EnforcedStyle, SupportedStyles. Style/MethodName: Enabled: false diff --git a/CHANGELOG.md b/CHANGELOG.md index 594e39fb..aec20f71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ### 0.9.2 (Next) +* [#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). * [#161](https://github.com/slack-ruby/slack-ruby-client/pull/161): Added support for cursor pagination - [@dblock](https://github.com/dblock). * Your contribution here. diff --git a/lib/slack-ruby-client.rb b/lib/slack-ruby-client.rb index 12d79387..f33cec71 100644 --- a/lib/slack-ruby-client.rb +++ b/lib/slack-ruby-client.rb @@ -17,6 +17,11 @@ rescue LoadError # ignore, only used in users_search end +begin + require 'openssl' +rescue LoadError + # Used in slack/web/config +end require_relative 'slack/web/config' require_relative 'slack/web/api/errors/slack_error' require_relative 'slack/web/api/errors/too_many_requests_error' diff --git a/lib/slack/web/config.rb b/lib/slack/web/config.rb index 128e1efc..0b5ca6d1 100644 --- a/lib/slack/web/config.rb +++ b/lib/slack/web/config.rb @@ -21,8 +21,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 diff --git a/lib/slack/web/faraday/connection.rb b/lib/slack/web/faraday/connection.rb index 9a10811f..2a9af04f 100644 --- a/lib/slack/web/faraday/connection.rb +++ b/lib/slack/web/faraday/connection.rb @@ -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 } if ca_path || ca_file request_options = {} request_options[:timeout] = timeout if timeout