Class: CertValidator::RealOcspValidator

Inherits:
Object
  • Object
show all
Includes:
OcspFailures
Defined in:
lib/cert_validator/ocsp/extractor.rb,
lib/cert_validator/ocsp/real_validator.rb

Defined Under Namespace

Classes: Extractor

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cert, ca) ⇒ RealOcspValidator

Returns a new instance of RealOcspValidator.



14
15
16
17
18
19
# File 'lib/cert_validator/ocsp/real_validator.rb', line 14

def initialize(cert, ca)
  @certificate = cert
  @ca = ca

  @extractor = Extractor.new @certificate
end

Instance Attribute Details

#caObject (readonly)

Returns the value of attribute ca.



9
10
11
# File 'lib/cert_validator/ocsp/real_validator.rb', line 9

def ca
  @ca
end

#certificateObject (readonly)

Returns the value of attribute certificate.



8
9
10
# File 'lib/cert_validator/ocsp/real_validator.rb', line 8

def certificate
  @certificate
end

#loggerObject

Returns the value of attribute logger.



10
11
12
# File 'lib/cert_validator/ocsp/real_validator.rb', line 10

def logger
  @logger
end

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/cert_validator/ocsp/real_validator.rb', line 21

def available?
  @extractor.has_ocsp_extension?
end

#valid?Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/cert_validator/ocsp/real_validator.rb', line 25

def valid?
  return false unless available?

  begin
    validate!
  rescue => e
    log e
    return false
  end
  
  return true
end

#validate!Object

Raises:



38
39
40
41
42
43
44
45
# File 'lib/cert_validator/ocsp/real_validator.rb', line 38

def validate!
  raise FetchError.new unless http_body = fetch(request_uri)
  
  body = OpenSSL::OCSP::Response.new http_body

  check_ocsp_response body
  check_ocsp_payload body.basic.status.first
end