mirror of
https://github.com/rest-client/rest-client.git
synced 2022-11-09 13:49:40 -05:00
Hook Windows CA code into default_ssl_cert_store.
This commit is contained in:
parent
3a55541e13
commit
d50274b530
1 changed files with 18 additions and 0 deletions
|
@ -294,9 +294,27 @@ module RestClient
|
|||
end
|
||||
end
|
||||
|
||||
# Return a certificate store that can be used to validate certificates with
|
||||
# the system certificate authorities. This will probably not do anything on
|
||||
# OS X, which monkey patches OpenSSL in terrible ways to insert its own
|
||||
# validation. On most *nix platforms, this will add the system certifcates
|
||||
# using OpenSSL::X509::Store#set_default_paths. On Windows, this will use
|
||||
# RestClient::Windows::RootCerts to look up the CAs trusted by the system.
|
||||
#
|
||||
# @return [OpenSSL::X509::Store]
|
||||
#
|
||||
def self.default_ssl_cert_store
|
||||
cert_store = OpenSSL::X509::Store.new
|
||||
cert_store.set_default_paths
|
||||
|
||||
# set_default_paths() doesn't do anything on Windows, so look up
|
||||
# certificates using the win32 API.
|
||||
if RestClient::Windows.windows?
|
||||
RestClient::Windows::RootCerts.instance.each do |cert|
|
||||
cert_store.add_cert(cert)
|
||||
end
|
||||
end
|
||||
|
||||
cert_store
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue