Skip to content

Commit

Permalink
Fix conditions for calling configure_ssl
Browse files Browse the repository at this point in the history
`env[:ssl]` is an instance of `Faraday::SSLOptions`, and as a result,
`configure_ssl` is always executed, even when the connection is to HTTP.
Fixes lostisland#37
  • Loading branch information
ma2gedev committed Jul 24, 2024
1 parent 1195316 commit f3d6a97
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/faraday/adapter/net_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ def initialize(app = nil, opts = {}, &block)

def build_connection(env)
net_http_connection(env).tap do |http|
http.use_ssl = env[:url].scheme == 'https' if http.respond_to?(:use_ssl=)
configure_ssl(http, env[:ssl])
if env[:url].scheme == 'https' && env[:ssl]
configure_ssl(http, env[:ssl])
end
configure_request(http, env[:request])
end
end
Expand Down Expand Up @@ -129,7 +130,7 @@ def save_http_response(env, http_response)
end

def configure_ssl(http, ssl)
return unless ssl
http.use_ssl = true if http.respond_to?(:use_ssl=)

http.verify_mode = ssl_verify_mode(ssl)
http.cert_store = ssl_cert_store(ssl)
Expand Down

0 comments on commit f3d6a97

Please sign in to comment.