mirror of
https://github.com/lostisland/faraday.git
synced 2025-08-29 00:03:58 -04:00
Fix ssl_verify_mode
ssl_verify_mode was referencing http, which resulted in: NameError: undefined local variable or method `http' for #<Faraday::Adapter::NetHttp:0x007fe8c2cc24e8>
This commit is contained in:
parent
44e53b140a
commit
f54bb91274
@ -82,25 +82,29 @@ module Faraday
|
||||
end
|
||||
|
||||
def configure_ssl(http, ssl)
|
||||
http.use_ssl = true
|
||||
http.verify_mode = ssl_verify_mode(ssl)
|
||||
http.use_ssl = true
|
||||
http.verify_mode = ssl_verify_mode(ssl)
|
||||
http.cert_store = ssl_cert_store(ssl)
|
||||
|
||||
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]
|
||||
http.ca_path = ssl[:ca_path] if ssl[:ca_path]
|
||||
http.cert_store = ssl[:cert_store] if ssl[:cert_store]
|
||||
http.verify_depth = ssl[:verify_depth] if ssl[:verify_depth]
|
||||
http.ssl_version = ssl[:version] if ssl[:version]
|
||||
end
|
||||
|
||||
def ssl_cert_store(ssl)
|
||||
return ssl[:cert_store] if ssl[:cert_store]
|
||||
# Use the default cert store by default, i.e. system ca certs
|
||||
cert_store = OpenSSL::X509::Store.new
|
||||
cert_store.set_default_paths
|
||||
cert_store
|
||||
end
|
||||
|
||||
def ssl_verify_mode(ssl)
|
||||
ssl[:verify_mode] || begin
|
||||
if ssl.fetch(:verify, true)
|
||||
# Use the default cert store by default, i.e. system ca certs
|
||||
store = OpenSSL::X509::Store.new
|
||||
store.set_default_paths
|
||||
http.cert_store = store
|
||||
OpenSSL::SSL::VERIFY_PEER
|
||||
else
|
||||
OpenSSL::SSL::VERIFY_NONE
|
||||
|
@ -24,12 +24,12 @@ module Faraday
|
||||
end
|
||||
|
||||
def configure_ssl(http, ssl)
|
||||
http.verify_mode = ssl_verify_mode(ssl)
|
||||
http.verify_mode = ssl_verify_mode(ssl)
|
||||
http.cert_store = ssl_cert_store(ssl)
|
||||
|
||||
http.certificate = ssl[:client_cert] if ssl[:client_cert]
|
||||
http.private_key = ssl[:client_key] if ssl[:client_key]
|
||||
http.ca_file = ssl[:ca_file] if ssl[:ca_file]
|
||||
http.cert_store = ssl[:cert_store] if ssl[:cert_store]
|
||||
http.ssl_version = ssl[:version] if ssl[:version]
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user