Class: R509::Crl::Parser
- Inherits:
-
Object
- Object
- R509::Crl::Parser
- Defined in:
- lib/r509/crl.rb
Instance Attribute Summary (collapse)
-
- (Object) crl
readonly
Returns the value of attribute crl.
Class Method Summary (collapse)
-
+ (R509::Crl::Parser) load_from_file(filename)
Helper method to quickly load a CRL from the filesystem.
Instance Method Summary (collapse)
-
- (Parser) initialize(crl)
constructor
A new instance of Parser.
- - (OpenSSL::X509::Name) issuer
-
- (String) issuer_cn
The common name (CN) component of the issuer.
- - (Time) last_update
- - (Time) next_update
-
- (Hash) revoked
Hash of serial => { :time, :reason } hashes.
- - (Boolean) revoked?(serial)
-
- (Hash) revoked_cert(serial)
Hash with :time and :reason.
- - (String) signature_algorithm
-
- (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).
Constructor Details
- (Parser) initialize(crl)
A new instance of Parser
14 15 16 |
# File 'lib/r509/crl.rb', line 14 def initialize(crl) @crl = OpenSSL::X509::CRL.new(crl) end |
Instance Attribute Details
- (Object) crl (readonly)
Returns the value of attribute crl
11 12 13 |
# File 'lib/r509/crl.rb', line 11 def crl @crl end |
Class Method Details
+ (R509::Crl::Parser) load_from_file(filename)
Helper method to quickly load a CRL from the filesystem
22 23 24 |
# File 'lib/r509/crl.rb', line 22 def self.load_from_file( filename ) return R509::Crl::Parser.new( IOHelpers.read_data(filename) ) end |
Instance Method Details
- (OpenSSL::X509::Name) issuer
27 28 29 |
# File 'lib/r509/crl.rb', line 27 def issuer @crl.issuer end |
- (String) issuer_cn
The common name (CN) component of the issuer
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/r509/crl.rb', line 32 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
44 45 46 |
# File 'lib/r509/crl.rb', line 44 def last_update @crl.last_update end |
- (Time) next_update
49 50 51 |
# File 'lib/r509/crl.rb', line 49 def next_update @crl.next_update end |
- (Hash) revoked
Hash of serial => { :time, :reason } hashes
77 78 79 80 81 82 83 84 85 |
# File 'lib/r509/crl.rb', line 77 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)
68 69 70 71 72 73 74 |
# File 'lib/r509/crl.rb', line 68 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
89 90 91 92 93 94 95 96 97 |
# File 'lib/r509/crl.rb', line 89 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
54 55 56 |
# File 'lib/r509/crl.rb', line 54 def signature_algorithm @crl.signature_algorithm 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)
62 63 64 |
# File 'lib/r509/crl.rb', line 62 def verify(public_key) @crl.verify(public_key) end |