Class: HammerCLI::SSLOptions
- Inherits:
-
Object
- Object
- HammerCLI::SSLOptions
- Defined in:
- lib/hammer_cli/ssloptions.rb
Constant Summary collapse
- DEFAULT_LOCAL_CA_STORE_PATH =
"~/.hammer/certs"
Instance Method Summary collapse
- #get_local_ca_store_path ⇒ Object
- #get_options(uri = nil) ⇒ Object
-
#initialize(options = {}) ⇒ SSLOptions
constructor
A new instance of SSLOptions.
Constructor Details
#initialize(options = {}) ⇒ SSLOptions
Returns a new instance of SSLOptions.
5 6 7 8 9 |
# File 'lib/hammer_cli/ssloptions.rb', line 5 def initialize(={}) @settings = .fetch(:settings, HammerCLI::Settings) @logger = .fetch(:logger, Logging.logger['SSLoptions']) @ca_manager = .fetch(:ca_manager, HammerCLI::CACertManager.new(DEFAULT_LOCAL_CA_STORE_PATH)) end |
Instance Method Details
#get_local_ca_store_path ⇒ Object
11 12 13 |
# File 'lib/hammer_cli/ssloptions.rb', line 11 def get_local_ca_store_path @settings.get(:ssl, :local_ca_store_path) || DEFAULT_LOCAL_CA_STORE_PATH end |
#get_options(uri = nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/hammer_cli/ssloptions.rb', line 15 def (uri = nil) = {} for sslopt in [:ssl_ca_file, :ssl_ca_path, :verify_ssl, :ssl_version] do ssloptval = read_ssl_option(sslopt) [sslopt] = ssloptval unless ssloptval.nil? end .merge!() # enable ssl verification [:verify_ssl] = true if [:verify_ssl].nil? if [:verify_ssl] && uri && ![:ssl_ca_file] && ![:ssl_ca_path] uri = URI.parse(uri) if uri.is_a?(String) if @ca_manager.cert_exist?(uri) [:ssl_ca_file] = @ca_manager.cert_file_name(uri) @logger.info("Matching CA cert was found in local CA store #{[:ssl_ca_file]}") end end [:ssl_ca_file, :ssl_ca_path].each do |opt| [opt] = File.([opt]) unless [opt].nil? end @logger.debug("SSL options: #{ApipieBindings::Utils::inspect_data()}") end |