Class: OpenSSL::X509::Certificate

Inherits:
Object
  • Object
show all
Defined in:
lib/rubygems/security.rb

Instance Method Summary collapse

Instance Method Details

#check_validity(issuer_cert = nil, time = Time.now) ⇒ Object

Check the validity of this certificate.



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/rubygems/security.rb', line 38

def check_validity(issuer_cert = nil, time = Time.now)
  ret = if @not_before && @not_before > time
    [false, :expired, "not valid before '#@not_before'"]
  elsif @not_after && @not_after < time
    [false, :expired, "not valid after '#@not_after'"]
  elsif issuer_cert && !verify(issuer_cert.public_key)
    [false, :issuer, "#{issuer_cert.subject} is not issuer"]
  else
    [true, :ok, 'Valid certificate']
  end

  # return hash
  { :is_valid => ret[0], :error => ret[1], :desc => ret[2] }
end