Class: MaxApiClient::CertificateStore

Inherits:
Object
  • Object
show all
Defined in:
lib/max_api_client/certificate_store.rb

Overview

Builds a TLS trust store from the system defaults and an optional CA file.

Class Method Summary collapse

Class Method Details

.build(ca_file:) ⇒ Object



12
13
14
15
16
17
# File 'lib/max_api_client/certificate_store.rb', line 12

def self.build(ca_file:)
  OpenSSL::X509::Store.new.tap do |store|
    store.set_default_paths
    store.add_file(ca_file) if ca_file
  end
end

.configure(http, ca_file:, verify_ssl:) ⇒ Object



6
7
8
9
10
# File 'lib/max_api_client/certificate_store.rb', line 6

def self.configure(http, ca_file:, verify_ssl:)
  http.use_ssl = true
  http.verify_mode = verify_ssl ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
  http.cert_store = build(ca_file:) if verify_ssl
end