Class: LetsCert::OpenSSLIOPlugin
- Defined in:
- lib/letscert/io_plugin.rb
Overview
OpenSSL IOPlugin
Constant Summary collapse
- PEM_RE =
/^-----BEGIN CERTIFICATE-----\n.*?\n-----END CERTIFICATE-----\n/m
Constants inherited from IOPlugin
Instance Attribute Summary
Attributes inherited from IOPlugin
Instance Method Summary collapse
-
#dump_key(key) ⇒ String
(also: #dump_cert)
Dump key/cert data.
-
#initialize(name, type) ⇒ OpenSSLIOPlugin
constructor
A new instance of OpenSSLIOPlugin.
-
#load_cert(data) ⇒ OpenSSL::X509::Certificate
Load certificate from raw
data. -
#load_key(data) ⇒ OpenSSL::PKey
Load key from raw
data.
Methods inherited from IOPlugin
empty_data, #load, register, registered, #save
Methods included from Loggable
Constructor Details
#initialize(name, type) ⇒ OpenSSLIOPlugin
Returns a new instance of OpenSSLIOPlugin.
195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/letscert/io_plugin.rb', line 195 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) ⇒ String Also known as: dump_cert
Dump key/cert data
217 218 219 220 221 222 223 224 |
# File 'lib/letscert/io_plugin.rb', line 217 def dump_key(key) case @type when :pem key.to_pem when :der key.to_der end end |
#load_cert(data) ⇒ OpenSSL::X509::Certificate
Load certificate from raw data
230 231 232 |
# File 'lib/letscert/io_plugin.rb', line 230 def load_cert(data) OpenSSL::X509::Certificate.new data end |
#load_key(data) ⇒ OpenSSL::PKey
Load key from raw data
210 211 212 |
# File 'lib/letscert/io_plugin.rb', line 210 def load_key(data) OpenSSL::PKey::RSA.new data end |