class R509::CRL::FileReaderWriter
File-based implementation of the CRL
reader/writer. Uses the crl_number_file
and crl_list_file
attributes in CAConfig
Attributes
crl_list_file[RW]
crl_number_file[RW]
Public Class Methods
new()
click to toggle source
# File lib/r509/crl/reader_writer.rb, line 39 def initialize @crl_number_file = nil @crl_list_file = nil end
Public Instance Methods
read_list() { |serial, reason, revoke_time| ... }
click to toggle source
Reads a CRL
list file from a file or StringIO @yield For each revoked certificate in the CRL
@yieldparam serial [Integer] revoked certificate's serial number @yieldparam reason [Integer,nil] reason for revocation. @yieldparam revoke_time [Integer]
# File lib/r509/crl/reader_writer.rb, line 49 def read_list return nil if @crl_list_file.nil? data = read_data(@crl_list_file) data.each_line do |line| line.chomp! serial, revoke_time, reason = line.split(',', 3) serial = serial.to_i reason = (reason == '') ? nil : reason.to_i revoke_time = (revoke_time == '') ? nil : revoke_time.to_i yield serial, reason, revoke_time end nil end
read_number()
click to toggle source
read the CRL
number from a file or StringIO
# File lib/r509/crl/reader_writer.rb, line 97 def read_number return 0 if @crl_number_file.nil? read_data(@crl_number_file).to_i end
remove_list_entry(serial)
click to toggle source
Remove a CRL
list entry @param serial [Integer] serial number of the certificate to remove from the list
# File lib/r509/crl/reader_writer.rb, line 78 def remove_list_entry(serial) return nil if @crl_list_file.nil? data = read_data(@crl_list_file) updated_list = [] data.each_line do |line| line.chomp! revoke_info = line.split(',', 3) if revoke_info[0].to_i != serial updated_list.push(line) end end write_data(@crl_list_file, updated_list.join("\n") + "\n") nil end
write_list_entry(serial, revoke_time, reason)
click to toggle source
Appends a CRL
list entry to a file or StringIO @param serial [Integer] serial number of the certificate to revoke @param reason [Integer,nil] reason for revocation @param revoke_time [Integer]
# File lib/r509/crl/reader_writer.rb, line 69 def write_list_entry(serial, revoke_time, reason) return nil if @crl_list_file.nil? entry = [serial, revoke_time, reason].join(",") write_data(@crl_list_file, entry + "\n", 'a:ascii-8bit') end
write_number(crl_number)
click to toggle source
write the CRL
number to a file or StringIO
# File lib/r509/crl/reader_writer.rb, line 104 def write_number(crl_number) return nil if @crl_number_file.nil? write_data(@crl_number_file, crl_number.to_s) end