Class: Serverspec::Type::X509PrivateKey
- Inherits:
-
Base
- Object
- Base
- Serverspec::Type::X509PrivateKey
show all
- Defined in:
- lib/serverspec/type/x509_private_key.rb
Instance Attribute Summary
Attributes inherited from Base
#name
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #inspect, #to_ary, #to_s
Instance Method Details
#encrypted? ⇒ Boolean
10
11
12
|
# File 'lib/serverspec/type/x509_private_key.rb', line 10
def encrypted?
@runner.run_command("grep -wq \"^Proc-Type.*ENCRYPTED$\" #{name}").exit_status == 0
end
|
#has_matching_certificate?(cert_file) ⇒ Boolean
14
15
16
17
18
|
# File 'lib/serverspec/type/x509_private_key.rb', line 14
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
|
#valid? ⇒ Boolean
5
6
7
8
|
# File 'lib/serverspec/type/x509_private_key.rb', line 5
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
|