class LetsCert::OpenSSLIOPlugin

OpenSSL IOPlugin @author Sylvain Daubert

Constants

PEM_RE

@private Regular expression to discriminate PEM

Public Class Methods

new(name, type) click to toggle source

@param [String] name filename @param [:pem,:der] type @raise [ArgumentError] unsupported type

Calls superclass method LetsCert::IOPlugin::new
# File lib/letscert/io_plugins/openssl_io_plugin.rb, line 34
def initialize(name, type)
  unless [:pem, :der].include? type
    raise ArgumentError, 'type should be :pem or :der'
  end

  @type = type
  super(name)
end

Public Instance Methods

dump_cert(key)
Alias for: dump_key
dump_key(key) click to toggle source

Dump key/cert data @param [OpenSSL::PKey] key @return [String]

# File lib/letscert/io_plugins/openssl_io_plugin.rb, line 53
def dump_key(key)
  case @type
  when :pem
    key.to_pem
  when :der
    key.to_der
  end
end
Also aliased as: dump_cert
load_cert(data) click to toggle source

Load certificate from raw data @param [String] data @return [OpenSSL::X509::Certificate]

# File lib/letscert/io_plugins/openssl_io_plugin.rb, line 66
def load_cert(data)
  OpenSSL::X509::Certificate.new data
end
load_key(data) click to toggle source

Load key from raw data @param [String] data @return [OpenSSL::PKey]

# File lib/letscert/io_plugins/openssl_io_plugin.rb, line 46
def load_key(data)
  OpenSSL::PKey::RSA.new data
end

Private Instance Methods

split_pems(data) { |m| ... } click to toggle source

Split concatenated PEMs. @param [String] data @yield [String] pem

# File lib/letscert/io_plugins/openssl_io_plugin.rb, line 75
def split_pems(data)
  my_data = data
  m = my_data.match(PEM_RE)
  while m
    yield m[0]
    my_data = my_data[m.end(0)..-1]
    m = my_data.match(PEM_RE)
  end
end