Class: R509::Crl::SignedList
- Inherits:
-
Object
- Object
- R509::Crl::SignedList
- Includes:
- IOHelpers
- Defined in:
- lib/r509/crl.rb
Overview
Parses CRLs
Instance Attribute Summary (collapse)
-
- (Object) crl
readonly
Returns the value of attribute crl.
Class Method Summary (collapse)
-
+ (R509::Crl::SignedList) load_from_file(filename)
Helper method to quickly load a CRL from the filesystem.
Instance Method Summary (collapse)
-
- (SignedList) initialize(crl)
constructor
A new instance of SignedList.
- - (OpenSSL::X509::Name) issuer
-
- (String) issuer_cn
The common name (CN) component of the issuer.
-
- (Time) last_update
Returns the signing time of the CRL.
-
- (Time) next_update
Returns the next update time for the CRL.
-
- (Hash) revoked
Hash of serial => { :time, :reason } hashes.
- - (Boolean) revoked?(serial)
-
- (Hash) revoked_cert(serial)
Hash with :time and :reason.
- - (String) signature_algorithm
-
- (String) to_der
Returns the CRL in DER format.
-
- (String) to_pem
(also: #to_s)
Returns the CRL in PEM format.
-
- (Boolean) verify(public_key)
Pass a public key to verify that the CRL is signed by a specific certificate (call cert.public_key on that object).
-
- (Object) write_der(filename_or_io)
Writes the CRL into the PEM format.
-
- (Object) write_pem(filename_or_io)
Writes the CRL into the PEM format.
Methods included from IOHelpers
#read_data, read_data, #write_data, write_data
Constructor Details
- (SignedList) initialize(crl)
A new instance of SignedList
16 17 18 |
# File 'lib/r509/crl.rb', line 16 def initialize(crl) @crl = OpenSSL::X509::CRL.new(crl) end |
Instance Attribute Details
- (Object) crl (readonly)
Returns the value of attribute crl
13 14 15 |
# File 'lib/r509/crl.rb', line 13 def crl @crl end |
Class Method Details
+ (R509::Crl::SignedList) load_from_file(filename)
Helper method to quickly load a CRL from the filesystem
24 25 26 |
# File 'lib/r509/crl.rb', line 24 def self.load_from_file( filename ) return R509::Crl::SignedList.new( IOHelpers.read_data(filename) ) end |
Instance Method Details
- (OpenSSL::X509::Name) issuer
29 30 31 |
# File 'lib/r509/crl.rb', line 29 def issuer @crl.issuer end |
- (String) issuer_cn
The common name (CN) component of the issuer
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/r509/crl.rb', line 34 def issuer_cn return nil if self.issuer.nil? self.issuer.to_a.each do |part, value, length| return value if part.upcase == 'CN' end # return nil if we didn't find a CN part return nil end |
- (Time) last_update
Returns the signing time of the CRL
69 70 71 |
# File 'lib/r509/crl.rb', line 69 def last_update @crl.last_update end |
- (Time) next_update
Returns the next update time for the CRL
76 77 78 |
# File 'lib/r509/crl.rb', line 76 def next_update @crl.next_update end |
- (Hash) revoked
Hash of serial => { :time, :reason } hashes
115 116 117 118 119 120 121 122 123 |
# File 'lib/r509/crl.rb', line 115 def revoked revoked_list = {} @crl.revoked.each do |revoked| reason = get_reason(revoked) revoked_list[revoked.serial.to_i] = { :time => revoked.time, :reason => reason } end revoked_list end |
- (Boolean) revoked?(serial)
90 91 92 93 94 95 96 |
# File 'lib/r509/crl.rb', line 90 def revoked?(serial) if @crl.revoked.find { |revoked| revoked.serial == serial } true else false end end |
- (Hash) revoked_cert(serial)
Hash with :time and :reason
127 128 129 130 131 132 133 134 135 |
# File 'lib/r509/crl.rb', line 127 def revoked_cert(serial) revoked = @crl.revoked.find { |revoked| revoked.serial == serial } if revoked reason = get_reason(revoked) { :time => revoked.time, :reason => reason } else nil end end |
- (String) signature_algorithm
46 47 48 |
# File 'lib/r509/crl.rb', line 46 def signature_algorithm @crl.signature_algorithm end |
- (String) to_der
Returns the CRL in DER format
110 111 112 |
# File 'lib/r509/crl.rb', line 110 def to_der @crl.to_der end |
- (String) to_pem Also known as: to_s
Returns the CRL in PEM format
101 102 103 |
# File 'lib/r509/crl.rb', line 101 def to_pem @crl.to_pem end |
- (Boolean) verify(public_key)
Pass a public key to verify that the CRL is signed by a specific certificate (call cert.public_key on that object)
84 85 86 |
# File 'lib/r509/crl.rb', line 84 def verify(public_key) @crl.verify(public_key) end |
- (Object) write_der(filename_or_io)
Writes the CRL into the PEM format
62 63 64 |
# File 'lib/r509/crl.rb', line 62 def write_der(filename_or_io) write_data(filename_or_io, @crl.to_der) end |
- (Object) write_pem(filename_or_io)
Writes the CRL into the PEM format
54 55 56 |
# File 'lib/r509/crl.rb', line 54 def write_pem(filename_or_io) write_data(filename_or_io, @crl.to_pem) end |