Sha256: e80f46b2f30048315914d5f91b97be4584a3e919badd021436a6ef0dda1c34dd

Contents?: true

Size: 732 Bytes

Versions: 30

Compression:

Stored size: 732 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)
      mac_op = "openssl sha -sha512"
      h1 = @runner.run_command("openssl x509 -noout -modulus -in #{cert_file} | #{mac_op}")
      h2 = @runner.run_command("openssl rsa -noout -modulus -in #{name} | #{mac_op}")
      (h1.stdout == h2.stdout) && (h1.exit_status == 0) && (h2.exit_status == 0)
    end
  end
end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
serverspec-ruby19-2.24.3 lib/serverspec/type/x509_private_key.rb
serverspec-2.29.0 lib/serverspec/type/x509_private_key.rb
serverspec-2.28.0 lib/serverspec/type/x509_private_key.rb
serverspec-2.27.0 lib/serverspec/type/x509_private_key.rb
serverspec-2.26.0 lib/serverspec/type/x509_private_key.rb
serverspec-2.25.0 lib/serverspec/type/x509_private_key.rb
serverspec-2.24.3 lib/serverspec/type/x509_private_key.rb
serverspec-2.24.2 lib/serverspec/type/x509_private_key.rb
serverspec-2.24.1 lib/serverspec/type/x509_private_key.rb
serverspec-2.24.0 lib/serverspec/type/x509_private_key.rb
serverspec-2.23.1 lib/serverspec/type/x509_private_key.rb
serverspec-2.23.0 lib/serverspec/type/x509_private_key.rb
serverspec-2.22.0 lib/serverspec/type/x509_private_key.rb
serverspec-2.21.1 lib/serverspec/type/x509_private_key.rb
serverspec-2.21.0 lib/serverspec/type/x509_private_key.rb
serverspec-2.20.0 lib/serverspec/type/x509_private_key.rb
serverspec-2.19.0 lib/serverspec/type/x509_private_key.rb
serverspec-2.18.0 lib/serverspec/type/x509_private_key.rb
serverspec-2.17.1 lib/serverspec/type/x509_private_key.rb
serverspec-2.17.0 lib/serverspec/type/x509_private_key.rb