Class: R509::Cert::Validator::CrlValidator

Inherits:
BasicValidator show all
Defined in:
lib/r509/cert/validator/crl_validator.rb

Instance Method Summary collapse

Methods inherited from BasicValidator

#initialize

Constructor Details

This class inherits a constructor from R509::Cert::Validator::BasicValidator

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


5
6
7
8
9
# File 'lib/r509/cert/validator/crl_validator.rb', line 5

def available?
  return false unless cdp
  return false if uris.empty?
  return true
end

#validate!(crl_file = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/r509/cert/validator/crl_validator.rb', line 11

def validate!(crl_file = nil)
  if !available? && crl_file.nil?
    raise Error.new "Tried to validate CRL but cert has no CRL data"
  end

  crl = unless crl_file.nil?
          File.read crl_file
        else
          get(uris.first)
        end

  body = R509::CRL::SignedList.new(crl)

  if @issuer
    unless body.verify @issuer.public_key
      raise CrlError.new "CRL did not match certificate"
    end
  end

  if body.revoked? @cert.serial
    raise CrlError.new "CRL listed certificate as revoked"
  end

  return true
end