class R509::CRL::SignedList

Parses CRLs

Attributes

crl[R]
issuer[R]

Public Class Methods

load_from_file(filename) click to toggle source

Helper method to quickly load a CRL from the filesystem

@param [String] filename Path to file you want to load @return [R509::CRL::SignedList] CRL object

# File lib/r509/crl/signed_list.rb, line 25
def self.load_from_file(filename)
  R509::CRL::SignedList.new(IOHelpers.read_data(filename))
end
new(crl) click to toggle source

@param [String,OpenSSL::X509::CRL] crl

# File lib/r509/crl/signed_list.rb, line 16
def initialize(crl)
  @crl = OpenSSL::X509::CRL.new(crl)
  @issuer = R509::Subject.new(@crl.issuer)
end

Public Instance Methods

last_update() click to toggle source

Returns the signing time of the CRL

@return [Time] when the CRL was signed

# File lib/r509/crl/signed_list.rb, line 53
def last_update
  @crl.last_update
end
next_update() click to toggle source

Returns the next update time for the CRL

@return [Time] when it will be updated next

# File lib/r509/crl/signed_list.rb, line 60
def next_update
  @crl.next_update
end
revoked() click to toggle source

@return [Hash] hash of serial => { :time, :reason } hashes

# File lib/r509/crl/signed_list.rb, line 99
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
revoked?(serial) click to toggle source

@param [Integer] serial number @return [Boolean]

# File lib/r509/crl/signed_list.rb, line 74
def revoked?(serial)
  if @crl.revoked.find { |revoked| revoked.serial == serial.to_i }
    true
  else
    false
  end
end
revoked_cert(serial) click to toggle source

@param [Integer] serial number @return [Hash] hash with :time and :reason

# File lib/r509/crl/signed_list.rb, line 111
def revoked_cert(serial)
  revoked = @crl.revoked.find { |r| r.serial == serial }
  if revoked
    reason = get_reason(revoked)
    { :time => revoked.time, :reason => reason }
  else
    nil
  end
end
signature_algorithm() click to toggle source

@return [String]

# File lib/r509/crl/signed_list.rb, line 30
def signature_algorithm
  @crl.signature_algorithm
end
to_der() click to toggle source

Returns the CRL in DER format

@return [String] the CRL in DER format

# File lib/r509/crl/signed_list.rb, line 94
def to_der
  @crl.to_der
end
to_pem() click to toggle source

Returns the CRL in PEM format

@return [String] the CRL in PEM format

# File lib/r509/crl/signed_list.rb, line 85
def to_pem
  @crl.to_pem
end
Also aliased as: to_s
to_s()
Alias for: to_pem
verify(public_key) click to toggle source

Pass a public key to verify that the CRL is signed by a specific certificate (call cert.public_key on that object)

@param [OpenSSL::PKey::PKey] public_key @return [Boolean]

# File lib/r509/crl/signed_list.rb, line 68
def verify(public_key)
  @crl.verify(public_key)
end
write_der(filename_or_io) click to toggle source

Writes the CRL into the PEM format

@param [String, write] filename_or_io Either a string of the path for

the file that you'd like to write, or an IO-like object.
# File lib/r509/crl/signed_list.rb, line 46
def write_der(filename_or_io)
  write_data(filename_or_io, @crl.to_der)
end
write_pem(filename_or_io) click to toggle source

Writes the CRL into the PEM format

@param [String, write] filename_or_io Either a string of the path for

the file that you'd like to write, or an IO-like object.
# File lib/r509/crl/signed_list.rb, line 38
def write_pem(filename_or_io)
  write_data(filename_or_io, @crl.to_pem)
end

Private Instance Methods

get_reason(revocation_object) click to toggle source
# File lib/r509/crl/signed_list.rb, line 123
def get_reason(revocation_object)
  reason = nil
  revocation_object.extensions.each do |extension|
    if extension.oid == "CRLReason"
      reason = extension.value
    end
  end

  reason
end