Class: ContainerConfig::Coercer::SslKey

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

Overview

SSL key type coercer

Instance Method Summary collapse

Instance Method Details

#coerce(value) ⇒ OpenSSL::PKey::RSA

Coerces the given value into an SSL key

Parameters:

  • value (Object)

    SSL key path

Returns:

  • (OpenSSL::PKey::RSA)

    coerced value



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 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

#nameObject

See Also:



12
13
14
# File 'lib/container_config/coercer/ssl_key.rb', line 12

def name
  "SSL Private Key"
end

#typeObject

See Also:



17
18
19
# File 'lib/container_config/coercer/ssl_key.rb', line 17

def type
  :ssl_key
end