Skip to content
Browse files

add SSLOptions

Found a case where the Typhoeus adapter uses different
keys than every other adapter.
  • Loading branch information...
1 parent d4ef6f4 commit a5e9485db1942d1d20b064da3181076961f3c85a @technoweenie committed Oct 21, 2012
Showing with 18 additions and 6 deletions.
  1. +4 −4 lib/faraday/adapter/typhoeus.rb
  2. +14 −2 lib/faraday/connection.rb
View
8 lib/faraday/adapter/typhoeus.rb
@@ -35,7 +35,7 @@ def request(env)
:method => env[:method],
:body => env[:body],
:headers => env[:request_headers],
- :disable_ssl_peer_verification => (env[:ssl] && !env[:ssl].fetch(:verify, true))
+ :disable_ssl_peer_verification => (env[:ssl] && env[:ssl].verify?)
configure_ssl req, env
configure_proxy req, env
@@ -65,8 +65,8 @@ def configure_ssl(req, env)
ssl = env[:ssl]
req.ssl_version = ssl[:version] if ssl[:version]
- req.ssl_cert = ssl[:client_cert_file] if ssl[:client_cert_file]
- req.ssl_key = ssl[:client_key_file] if ssl[:client_key_file]
+ req.ssl_cert = ssl[:client_cert] if ssl[:client_cert]
+ req.ssl_key = ssl[:client_key] if ssl[:client_key]
req.ssl_cacert = ssl[:ca_file] if ssl[:ca_file]
req.ssl_capath = ssl[:ca_path] if ssl[:ca_path]
end
@@ -88,7 +88,7 @@ def configure_timeout(req, env)
req.timeout = req.connect_timeout = (env_req[:timeout] * 1000) if env_req[:timeout]
req.connect_timeout = (env_req[:open_timeout] * 1000) if env_req[:open_timeout]
end
-
+
def configure_socket(req, env)
if bind = request_options(env)[:bind]
req.interface = bind[:host]
View
16 lib/faraday/connection.rb
@@ -492,17 +492,29 @@ def params_encoder
end
end
+ class SSLOptions < Faraday::Options.new(:verify, :ca_file, :ca_path,
+ :cert_store, :client_cert, :client_key, :verify_depth, :version)
+
+ def verify?
+ verify != false
+ end
+
+ def disable?
+ !verify?
+ end
+ end
+
class Options < Faraday::Options.new(:request, :proxy, :ssl, :builder,
:parallel_manager, :params, :headers, :url)
- options :request => RequestOptions
+ options :request => RequestOptions, :ssl => SSLOptions
def request
self[:request] ||= self.class.options_for(:request).new
end
def ssl
- self[:ssl] ||= {}
+ self[:ssl] ||= self.class.options_for(:ssl).new
end
end
end

0 comments on commit a5e9485

Please sign in to comment.
Something went wrong with that request. Please try again.