mirror of
https://github.com/inspec/inspec
synced 2024-11-23 21:23:29 +00:00
Refactors key_rsa resource (#2627)
Signed-off-by: kagarmoe <kgarmoe@chef.io>
This commit is contained in:
parent
78f51f8d9c
commit
e5cacc3105
1 changed files with 24 additions and 14 deletions
|
@ -1,5 +1,6 @@
|
|||
---
|
||||
title: The key_rsa Resource
|
||||
os: Linux
|
||||
---
|
||||
|
||||
# key_rsa
|
||||
|
@ -31,13 +32,11 @@ You can use an optional passphrase with `key_rsa`
|
|||
|
||||
## Supported Properties
|
||||
|
||||
### public?
|
||||
* `public_key`, `private_key`, `key_length`
|
||||
|
||||
To verify if a key is public use the following:
|
||||
<br>
|
||||
|
||||
describe key_rsa('/etc/pki/www.mywebsite.com.key') do
|
||||
it { should be_public }
|
||||
end
|
||||
## Property Examples
|
||||
|
||||
### public_key (String)
|
||||
|
||||
|
@ -47,15 +46,6 @@ The `public_key` property returns the public part of the RSA key pair
|
|||
its('public_key') { should match "-----BEGIN PUBLIC KEY-----\n3597459df9f3982......" }
|
||||
end
|
||||
|
||||
### private?
|
||||
|
||||
This property verifies that the key includes a private key:
|
||||
|
||||
describe key_rsa('/etc/pki/www.mywebsite.com.key') do
|
||||
it { should be_private }
|
||||
end
|
||||
|
||||
|
||||
### private_key (String)
|
||||
|
||||
The `private_key` property returns the private key or the RSA key pair.
|
||||
|
@ -71,3 +61,23 @@ The `key_length` property allows testing the number of bits in the key pair.
|
|||
describe key_rsa('/etc/pki/www.mywebsite.com.key') do
|
||||
its('key_length') { should eq 2048 }
|
||||
end
|
||||
|
||||
## Matchers
|
||||
|
||||
For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
|
||||
|
||||
### public?
|
||||
|
||||
To verify if a key is public use the following:
|
||||
|
||||
describe key_rsa('/etc/pki/www.mywebsite.com.key') do
|
||||
it { should be_public }
|
||||
end
|
||||
|
||||
### private?
|
||||
|
||||
This property verifies that the key includes a private key:
|
||||
|
||||
describe key_rsa('/etc/pki/www.mywebsite.com.key') do
|
||||
it { should be_private }
|
||||
end
|
Loading…
Reference in a new issue