Sha256: 58a5f9cdfdacf877167318d01b55139d6fdffe3570476bde4b068091865d88e2

Contents?: true

Size: 671 Bytes

Versions: 19

Compression:

Stored size: 671 Bytes

Contents

require 'time'

module Serverspec::Type
  class X509PrivateKey < Base
    def valid?
      runner_res = @runner.run_command("openssl rsa -in #{name} -check -noout")
      ( runner_res.exit_status == 0 && runner_res.stdout.chomp == 'RSA key ok' )
    end

    def encrypted?
      @runner.run_command("grep -wq \"^Proc-Type.*ENCRYPTED$\" #{name}").exit_status == 0
    end

    def has_matching_certificate?(cert_file)
      h1 = @runner.run_command("openssl x509 -noout -modulus -in #{cert_file}")
      h2 = @runner.run_command("openssl rsa -noout -modulus -in #{name}")
      (h1.stdout == h2.stdout) && (h1.exit_status == 0) && (h2.exit_status == 0)
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
serverspec-2.39.1 lib/serverspec/type/x509_private_key.rb
serverspec-2.39.0 lib/serverspec/type/x509_private_key.rb
serverspec-2.38.1 lib/serverspec/type/x509_private_key.rb
serverspec-2.38.0 lib/serverspec/type/x509_private_key.rb
serverspec-2.37.2 lib/serverspec/type/x509_private_key.rb
serverspec-2.37.1 lib/serverspec/type/x509_private_key.rb
serverspec-2.37.0 lib/serverspec/type/x509_private_key.rb
serverspec-2.36.1 lib/serverspec/type/x509_private_key.rb
serverspec-2.36.0 lib/serverspec/type/x509_private_key.rb
serverspec-2.35.0 lib/serverspec/type/x509_private_key.rb
serverspec-2.34.0 lib/serverspec/type/x509_private_key.rb
serverspec-2.33.0 lib/serverspec/type/x509_private_key.rb
serverspec-2.32.0 lib/serverspec/type/x509_private_key.rb
serverspec-2.31.1 lib/serverspec/type/x509_private_key.rb
serverspec-2.31.0 lib/serverspec/type/x509_private_key.rb
serverspec-2.30.1 lib/serverspec/type/x509_private_key.rb
serverspec-2.30.0 lib/serverspec/type/x509_private_key.rb
serverspec-2.29.2 lib/serverspec/type/x509_private_key.rb
serverspec-2.29.1 lib/serverspec/type/x509_private_key.rb