class CertValidator::CrlValidator::Extractor

Attributes

certificate[R]

Public Class Methods

new(cert) click to toggle source
# File lib/cert_validator/crl/extractor.rb, line 6
def initialize(cert)
  @certificate = cert
end

Public Instance Methods

crl_extension() click to toggle source
# File lib/cert_validator/crl/extractor.rb, line 23
def crl_extension
  @crl_extension ||= certificate.extensions.detect{ |e| e.oid == 'crlDistributionPoints' }
end
crl_extension_payload() click to toggle source
# File lib/cert_validator/crl/extractor.rb, line 27
def crl_extension_payload
  @crl_extension_payload ||= Asn1.new(crl_extension.to_der).extension_payload
end
decoded_payload() click to toggle source
# File lib/cert_validator/crl/extractor.rb, line 31
def decoded_payload
  @decoded_payload ||= Asn1.new(crl_extension_payload).decode
end
descend_to_string(asn_data) click to toggle source
# File lib/cert_validator/crl/extractor.rb, line 35
def descend_to_string(asn_data)
  seen = Set.new
  current = asn_data
  loop do
    raise RecursiveExtractError.new if seen.include? current
    seen.add current
    current = current.first.value

    return current if current.is_a? String
  end
end
distribution_points() click to toggle source
# File lib/cert_validator/crl/extractor.rb, line 10
def distribution_points
  return [] unless has_crl_extension?
  decoded_payload.value.map{ |v| descend_to_string v.value }
end
has_crl_extension?() click to toggle source
# File lib/cert_validator/crl/extractor.rb, line 19
def has_crl_extension?
  !! crl_extension
end
has_distribution_points?() click to toggle source
# File lib/cert_validator/crl/extractor.rb, line 15
def has_distribution_points?
  ! distribution_points.empty?
end