Sha256: a319c8ddd4a5073a755ee798416b6e460e8f48adb51e07b3fc312ba2c2f9d942

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

require "r509"

module R509::Validity::Redis
    class Checker < R509::Validity::Checker
        def initialize(redis)
            raise ArgumentError.new("Redis must be provided") if redis.nil?
            @redis = redis
        end

        # @return [R509::Validity::Status]
        def check(issuer,serial)
            raise ArgumentError.new("Serial and issuer must be provided") if serial.to_s.empty? or issuer.to_s.empty?

            hash = @redis.hgetall("cert:#{issuer}:#{serial}")
            if not hash.nil? and hash.has_key?("status")
                R509::Validity::Status.new(
                    :status => hash["status"].to_i,
                    :revocation_time => hash["revocation_time"].to_i || nil,
                    :revocation_reason => hash["revocation_reason"].to_i || 0
                )
            else
                R509::Validity::Status.new(:status => R509::Validity::UNKNOWN)
            end
        end

        def is_available?
            (@redis.ping == "PONG")? true : false
        end
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
r509-validity-redis-0.4.1 lib/r509/validity/redis/checker.rb
r509-validity-redis-0.4 lib/r509/validity/redis/checker.rb
r509-validity-redis-0.3 lib/r509/validity/redis/checker.rb