class ContainerConfig::Coercer::SslKey

SSL key type coercer

Public Instance Methods

coerce(value) click to toggle source

Coerces the given value into an SSL key

@param [Object] value SSL key path

@return [OpenSSL::PKey::RSA] coerced value

# File lib/container_config/coercer/ssl_key.rb, line 28
def coerce(value)
  return if value.nil?

  key_path = value.to_s

  unless File.exist?(key_path)
    ContainerConfig.logger.warn { "Could not find SSL key at #{key_path}" }
    return
  end

  OpenSSL::PKey::RSA.new(File.read(key_path))
rescue OpenSSL::PKey::RSAError => e
  ContainerConfig.logger.warn { "Could not parse SSL key #{key_path} successfully: #{e}" }
  nil
end
name() click to toggle source

@see ContainerConfig::Coercer::Base#name

# File lib/container_config/coercer/ssl_key.rb, line 12
def name
  "SSL Private Key"
end
type() click to toggle source

@see ContainerConfig::Coercer::Base#type

# File lib/container_config/coercer/ssl_key.rb, line 17
def type
  :ssl_key
end