lib/httparty/connection_adapter.rb in httparty-0.16.3 vs lib/httparty/connection_adapter.rb in httparty-0.16.4
- old
+ new
@@ -75,10 +75,16 @@
# Public
def self.call(uri, options)
new(uri, options).connection
end
+ def self.default_cert_store
+ @default_cert_store ||= OpenSSL::X509::Store.new.tap do |cert_store|
+ cert_store.set_default_paths
+ end
+ end
+
attr_reader :uri, :options
def initialize(uri, options = {})
uri_adapter = options[:uri_adapter] || URI
raise ArgumentError, "uri must be a #{uri_adapter}, not a #{uri.class}" unless uri.is_a? uri_adapter
@@ -174,11 +180,10 @@
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
if options[:cert_store]
http.cert_store = options[:cert_store]
else
# Use the default cert store by default, i.e. system ca certs
- http.cert_store = OpenSSL::X509::Store.new
- http.cert_store.set_default_paths
+ http.cert_store = self.class.default_cert_store
end
else
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end