1
0
Fork 0
mirror of https://github.com/jnunemaker/httparty synced 2023-03-27 23:23:07 -04:00

Cache default certs store (#625)

This commit is contained in:
Dalibor Nasevic 2019-01-21 15:17:54 +01:00 committed by Nikita Misharin
parent d84a05b69e
commit 43519c4000
2 changed files with 12 additions and 2 deletions

View file

@ -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

View file

@ -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