class CertValidator::RealOcspValidator::Extractor

Attributes

certificate[R]

Public Class Methods

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

Public Instance Methods

decoded_extension() click to toggle source
# File lib/cert_validator/ocsp/extractor.rb, line 24
def decoded_extension
  @decoded_extension ||= Asn1.new(Asn1.new(ocsp_extension).extension_payload).decode
end
descend_to_string(asn_data) click to toggle source
# File lib/cert_validator/ocsp/extractor.rb, line 38
def descend_to_string(asn_data)
  return asn_data if asn_data.is_a? String
  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
endpoint() click to toggle source
# File lib/cert_validator/ocsp/extractor.rb, line 10
def endpoint
  return nil unless has_ocsp_extension?

  ocsp_extension_payload
end
has_ocsp_extension?() click to toggle source
# File lib/cert_validator/ocsp/extractor.rb, line 16
def has_ocsp_extension?
  !! (ocsp_extension && ocsp_extension_payload)
end
ocsp_extension() click to toggle source
# File lib/cert_validator/ocsp/extractor.rb, line 20
def ocsp_extension
  @ocsp_extension ||= certificate.extensions.detect{ |e| e.oid == 'authorityInfoAccess' }
end
ocsp_extension_payload() click to toggle source
# File lib/cert_validator/ocsp/extractor.rb, line 28
def ocsp_extension_payload
  return @ocsp_extension_payload if defined? @ocsp_extension_payload

  intermediate = decoded_extension.value.detect do |v|
    v.first.value == 'OCSP'
  end.value[1].value

  @ocsp_extension_payload = descend_to_string(intermediate)
end