diff --git a/lib/httparty/connection_adapter.rb b/lib/httparty/connection_adapter.rb index 5b5193a..654168e 100644 --- a/lib/httparty/connection_adapter.rb +++ b/lib/httparty/connection_adapter.rb @@ -77,6 +77,12 @@ module HTTParty 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 = {}) @@ -176,8 +182,7 @@ module HTTParty 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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d8622a4..c638b91 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -37,6 +37,11 @@ RSpec.configure do |config| config.order = :random + config.before(:each) do + # Reset default_cert_store cache + HTTParty::ConnectionAdapter.instance_variable_set(:@default_cert_store, nil) + end + Kernel.srand config.seed end