Sha256: 0d72660762c2dab08aaf8dca644cafa7bca69be55f62849d6fcd1328744f12dc

Contents?: true

Size: 1.15 KB

Versions: 6

Compression:

Stored size: 1.15 KB

Contents

module Outliers
  module Resources
    module Aws
      module Elb
        class LoadBalancer < Resource

          def ssl_certificates_valid?(args)
            days = args
            pass = true

            logger.debug "Load Balancer '#{id}' has no certificates." unless certificates.any?

            date = Time.now + (days.to_i * 86400)

            logger.debug "Validating no certs expire before '#{date.to_s}'."

            certificates.each do |c|
              certificate = OpenSSL::X509::Certificate.new c.certificate_body
              subject     = certificate.subject
              not_after   = certificate.not_after

              logger.debug "Certificate '#{subject}' expires '#{not_after}'."
              result = not_after > date
              logger.debug "Certificate #{result ? "valid" : "invalid"}."
              pass = false unless result
            end
            pass
          end

          private

          def certificates
            listeners.map {|l| l.server_certificate}.reject {|s| s.nil?}
          end

          def listeners
            @listeners ||= source.listeners
          end

        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
outliers-0.6.0 lib/outliers/resources/aws/elb/load_balancer.rb
outliers-0.5.1 lib/outliers/resources/aws/elb/load_balancer.rb
outliers-0.5.0 lib/outliers/resources/aws/elb/load_balancer.rb
outliers-0.5.0.beta3 lib/outliers/resources/aws/elb/load_balancer.rb
outliers-0.5.0.beta2 lib/outliers/resources/aws/elb/load_balancer.rb
outliers-0.5.0.beta1 lib/outliers/resources/aws/elb/load_balancer.rb