Skip to content

Commit

Permalink
feat: add Ciphers option to SSL Option
Browse files Browse the repository at this point in the history
  • Loading branch information
saiqulhaq committed Sep 14, 2024
1 parent c7d0dfb commit 8a5b8a7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ source 'https://rubygems.org'
gemspec

gem 'faraday', '>= 1.0'

gem 'rake', '~> 13.0'
gem 'rspec', '~> 3.0'
gem 'simplecov', '~> 0.19.0'
gem 'simplecov', '~> 0.22.0'

gem 'webmock', '~> 3.4'

gem 'rubocop', '~> 1.12.0'
less_than_ruby_v27 = Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7.0')
gem 'rubocop', less_than_ruby_v27 ? '~> 1.12.0' : '~> 1.66.0'
gem 'rubocop-packaging', '~> 0.5'
gem 'rubocop-performance', '~> 1.0'
gem 'rubocop-performance', '~> 1.20'
14 changes: 13 additions & 1 deletion lib/faraday/adapter/httpclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def call(env)

if (req = env[:request]).stream_response?
warn "Streaming downloads for #{self.class.name} " \
'are not yet implemented.'
'are not yet implemented.'
req.on_data.call(resp.body, resp.body.bytesize)
end
save_response env, resp.status, resp.body, resp.headers, resp.reason
Expand Down Expand Up @@ -101,6 +101,11 @@ def configure_ssl(client, ssl)
ssl_config.add_trust_ca ssl[:ca_path] if ssl[:ca_path]
ssl_config.client_cert = ssl[:client_cert] if ssl[:client_cert]
ssl_config.client_key = ssl[:client_key] if ssl[:client_key]

if support_ciphers?(ssl)
ssl_config.ciphers = ssl[:ciphers]
end

ssl_config.verify_depth = ssl[:verify_depth] if ssl[:verify_depth]
end

Expand Down Expand Up @@ -147,6 +152,13 @@ def ssl_verify_mode(ssl)
end
end
end

private

def support_ciphers?(ssl_param)
Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.11.0') &&
ssl_param.respond_to?(:ciphers=)
end
end
end
end

0 comments on commit 8a5b8a7

Please sign in to comment.