Skip to content

Commit 8a5b8a7

Browse files
committed
feat: add Ciphers option to SSL Option
1 parent c7d0dfb commit 8a5b8a7

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

Gemfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ source 'https://rubygems.org'
44
gemspec
55

66
gem 'faraday', '>= 1.0'
7-
87
gem 'rake', '~> 13.0'
98
gem 'rspec', '~> 3.0'
10-
gem 'simplecov', '~> 0.19.0'
9+
gem 'simplecov', '~> 0.22.0'
1110

1211
gem 'webmock', '~> 3.4'
1312

14-
gem 'rubocop', '~> 1.12.0'
13+
less_than_ruby_v27 = Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7.0')
14+
gem 'rubocop', less_than_ruby_v27 ? '~> 1.12.0' : '~> 1.66.0'
1515
gem 'rubocop-packaging', '~> 0.5'
16-
gem 'rubocop-performance', '~> 1.0'
16+
gem 'rubocop-performance', '~> 1.20'

lib/faraday/adapter/httpclient.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def call(env)
4848

4949
if (req = env[:request]).stream_response?
5050
warn "Streaming downloads for #{self.class.name} " \
51-
'are not yet implemented.'
51+
'are not yet implemented.'
5252
req.on_data.call(resp.body, resp.body.bytesize)
5353
end
5454
save_response env, resp.status, resp.body, resp.headers, resp.reason
@@ -101,6 +101,11 @@ def configure_ssl(client, ssl)
101101
ssl_config.add_trust_ca ssl[:ca_path] if ssl[:ca_path]
102102
ssl_config.client_cert = ssl[:client_cert] if ssl[:client_cert]
103103
ssl_config.client_key = ssl[:client_key] if ssl[:client_key]
104+
105+
if support_ciphers?(ssl)
106+
ssl_config.ciphers = ssl[:ciphers]
107+
end
108+
104109
ssl_config.verify_depth = ssl[:verify_depth] if ssl[:verify_depth]
105110
end
106111

@@ -147,6 +152,13 @@ def ssl_verify_mode(ssl)
147152
end
148153
end
149154
end
155+
156+
private
157+
158+
def support_ciphers?(ssl_param)
159+
Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.11.0') &&
160+
ssl_param.respond_to?(:ciphers=)
161+
end
150162
end
151163
end
152164
end

0 commit comments

Comments
 (0)