mirror of
https://github.com/lostisland/faraday.git
synced 2025-08-29 00:03:58 -04:00
make SSL peer verification as default. disable with connection.ssl[:verify] = false
This commit is contained in:
parent
121080f7e2
commit
ddc41641b2
@ -12,10 +12,8 @@ module Faraday
|
||||
|
||||
conn = ::Excon.new(env[:url].to_s)
|
||||
if ssl = (env[:url].scheme == 'https' && env[:ssl])
|
||||
::Excon.ssl_verify_peer = !!ssl[:verify] if ssl.key?(:verify)
|
||||
if ca_file = ssl[:ca_file]
|
||||
::Excon.ssl_ca_path = ca_file
|
||||
end
|
||||
::Excon.ssl_verify_peer = !!ssl.fetch(:verify, true)
|
||||
::Excon.ssl_ca_path = ssl[:ca_file] if ssl[:ca_file]
|
||||
end
|
||||
|
||||
resp = conn.request \
|
||||
|
@ -15,13 +15,10 @@ module Faraday
|
||||
|
||||
http = net_http_class(env).new(url.host, url.port)
|
||||
|
||||
if http.use_ssl = url.scheme == 'https'
|
||||
if http.use_ssl = (url.scheme == 'https' && env[:ssl])
|
||||
ssl = env[:ssl]
|
||||
http.verify_mode = case ssl[:verify]
|
||||
when false then OpenSSL::SSL::VERIFY_NONE
|
||||
when true then OpenSSL::SSL::VERIFY_PEER
|
||||
else ssl[:verify]
|
||||
end
|
||||
http.verify_mode = ssl[:verify_mode] || ssl.fetch(:verify, true) ?
|
||||
OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
|
||||
http.cert = ssl[:client_cert] if ssl[:client_cert]
|
||||
http.key = ssl[:client_key] if ssl[:client_key]
|
||||
http.ca_file = ssl[:ca_file] if ssl[:ca_file]
|
||||
|
@ -23,7 +23,7 @@ module Faraday
|
||||
:method => env[:method],
|
||||
:body => env[:body],
|
||||
:headers => env[:request_headers],
|
||||
:disable_ssl_peer_verification => (env[:ssl][:verify] == false)
|
||||
:disable_ssl_peer_verification => (env[:ssl] && !env[:ssl].fetch(:verify, true))
|
||||
|
||||
env_req = env[:request]
|
||||
req.timeout = req.connect_timeout = (env_req[:timeout] * 1000) if env_req[:timeout]
|
||||
|
Loading…
x
Reference in New Issue
Block a user