Class: ContainerConfig::Coercer::SslVerifyMode

Inherits:
Base
  • Object
show all
Defined in:
lib/container_config/coercer/ssl_verify_mode.rb

Overview

SSL verification mode type coercer

Constant Summary collapse

VALID_MODES =

Array of valid SSL verification modes

OpenSSL::SSL.constants.select { |c| c.to_s.start_with?("VERIFY") }.map(&:to_s)

Instance Method Summary collapse

Instance Method Details

#coerce(value) ⇒ Integer

Coerces the given value into an SSL verification mode

Parameters:

  • value (Object)

    SSL verification mode string (“VERIFY_NONE”, “VERIFY_PEER”, etc.)

Returns:



31
32
33
34
35
36
37
38
39
# File 'lib/container_config/coercer/ssl_verify_mode.rb', line 31

def coerce(value)
  value = value.to_s
  return Object.const_get("OpenSSL::SSL::#{value}") if VALID_MODES.include?(value)

  ContainerConfig.logger.warn do
    "Could not convert #{value.inspect} into a valid OpenSSL verification mode.\nValid modes: #{VALID_MODES.join(", ")}"
  end
  nil
end

#nameObject

See Also:



15
16
17
# File 'lib/container_config/coercer/ssl_verify_mode.rb', line 15

def name
  "SSL Verification Mode"
end

#typeObject

See Also:



20
21
22
# File 'lib/container_config/coercer/ssl_verify_mode.rb', line 20

def type
  :ssl_verify_mode
end