class OpenSSL::X509::Certificate

Public Instance Methods

check_validity(issuer_cert = nil, time = Time.now) click to toggle source

Check the validity of this certificate.

# File lib/rubygems/gem_openssl.rb, line 51
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