Class: LetsCert::OpenSSLIOPlugin

Inherits:
IOPlugin
  • Object
show all
Defined in:
lib/letscert/io_plugin.rb

Overview

OpenSSL IOPlugin

Direct Known Subclasses

CertFile, ChainFile, KeyFile

Constant Summary collapse

PEM_RE =
/
^-----BEGIN ((?:[\x21-\x2c\x2e-\x7e](?:[- ]?[\x21-\x2c\x2e-\x7e])*)?)\s*-----$
.*?
^-----END \1-----\s*
/x

Constants inherited from IOPlugin

IOPlugin::ALLOWED_PLUGINS

Instance Attribute Summary

Attributes inherited from IOPlugin

#name

Instance Method Summary collapse

Methods inherited from IOPlugin

empty_data, #load, #logger, logger=, register, registered, #save

Constructor Details

#initialize(name, type) ⇒ OpenSSLIOPlugin

Returns a new instance of OpenSSLIOPlugin.



199
200
201
202
203
204
205
206
207
208
209
# File 'lib/letscert/io_plugin.rb', line 199

def initialize(name, type)
  case type
  when :pem
  when :der
  else
    raise ArgumentError, "type should be :pem or :der"
  end

  @type = type
  super(name)
end

Instance Method Details

#dump_key(key) ⇒ Object Also known as: dump_cert



215
216
217
218
219
220
221
222
# File 'lib/letscert/io_plugin.rb', line 215

def dump_key(key)
  case @type
  when :pem
    key.to_pem
  when :der
    key.to_der
  end
end

#load_cert(data) ⇒ Object



225
226
227
# File 'lib/letscert/io_plugin.rb', line 225

def load_cert(data)
  OpenSSL::X509::Certificate.new data
end

#load_key(data) ⇒ Object



211
212
213
# File 'lib/letscert/io_plugin.rb', line 211

def load_key(data)
  OpenSSL::PKey::RSA.new data
end