2018-12-18 10:07:36 +01:00
|
|
|
---
|
2017-08-21 13:19:41 +02:00
|
|
|
- name: Validate privatekey1 (test - RSA key with size 4096 bits)
|
2018-10-17 21:29:18 +02:00
|
|
|
shell: "openssl rsa -noout -text -in {{ output_dir }}/privatekey1.pem | grep Private | sed 's/\\(RSA\\s\\)*Private-Key: (\\(.*\\) bit.*)/\\2/'"
|
2017-07-25 13:18:18 +02:00
|
|
|
register: privatekey1
|
|
|
|
|
2017-08-21 13:19:41 +02:00
|
|
|
- name: Validate privatekey1 (assert - RSA key with size 4096 bits)
|
2017-07-25 13:18:18 +02:00
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- privatekey1.stdout == '4096'
|
|
|
|
|
|
|
|
|
2017-08-21 13:19:41 +02:00
|
|
|
- name: Validate privatekey2 (test - RSA key with size 2048 bits)
|
2018-10-17 21:29:18 +02:00
|
|
|
shell: "openssl rsa -noout -text -in {{ output_dir }}/privatekey2.pem | grep Private | sed 's/\\(RSA\\s\\)*Private-Key: (\\(.*\\) bit.*)/\\2/'"
|
2017-07-25 13:18:18 +02:00
|
|
|
register: privatekey2
|
|
|
|
|
2017-08-21 13:19:41 +02:00
|
|
|
- name: Validate privatekey2 (assert - RSA key with size 2048 bits)
|
2017-07-25 13:18:18 +02:00
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- privatekey2.stdout == '2048'
|
|
|
|
|
|
|
|
|
2018-12-18 10:07:36 +01:00
|
|
|
- name: Validate privatekey3 (test - DSA key with size 3072 bits)
|
2018-10-17 21:29:18 +02:00
|
|
|
shell: "openssl dsa -noout -text -in {{ output_dir }}/privatekey3.pem | grep Private | sed 's/\\(RSA\\s\\)*Private-Key: (\\(.*\\) bit.*)/\\2/'"
|
2017-07-25 13:18:18 +02:00
|
|
|
register: privatekey3
|
|
|
|
|
2018-12-18 10:07:36 +01:00
|
|
|
- name: Validate privatekey3 (assert - DSA key with size 3072 bits)
|
2017-07-25 13:18:18 +02:00
|
|
|
assert:
|
|
|
|
that:
|
2018-12-18 10:07:36 +01:00
|
|
|
- privatekey3.stdout == '3072'
|
2017-08-21 13:19:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
- name: Validate privatekey4 (test - Ensure key has been removed)
|
|
|
|
stat:
|
|
|
|
path: '{{ output_dir }}/privatekey4.pem'
|
|
|
|
register: privatekey4
|
|
|
|
|
|
|
|
- name: Validate privatekey4 (assert - Ensure key has been removed)
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- privatekey4.stat.exists == False
|
|
|
|
|
|
|
|
|
|
|
|
- name: Validate privatekey5 (test - Passphrase protected key + idempotence)
|
2018-10-17 21:29:18 +02:00
|
|
|
shell: "openssl rsa -noout -text -in {{ output_dir }}/privatekey5.pem -passin pass:ansible | grep Private | sed 's/\\(RSA\\s\\)*Private-Key: (\\(.*\\) bit.*)/\\2/'"
|
2017-08-21 13:19:41 +02:00
|
|
|
register: privatekey5
|
|
|
|
# Current version of OS/X that runs in the CI (10.11) does not have an up to date version of the OpenSSL library
|
|
|
|
# leading to this test to fail when run in the CI. However, this test has been run for 10.12 and has returned succesfully.
|
2017-11-27 23:58:08 +01:00
|
|
|
when: openssl_version.stdout is version('0.9.8zh', '>=')
|
2017-08-21 13:19:41 +02:00
|
|
|
|
|
|
|
- name: Validate privatekey5 (assert - Passphrase protected key + idempotence)
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- privatekey5.stdout == '4096'
|
2017-11-27 23:58:08 +01:00
|
|
|
when: openssl_version.stdout is version('0.9.8zh', '>=')
|
2017-08-21 13:19:41 +02:00
|
|
|
|
|
|
|
- name: Validate privatekey5 idempotence (assert - Passphrase protected key + idempotence)
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- privatekey5_idempotence is not changed
|
2017-08-21 13:19:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
- name: Validate privatekey6 (test - Passphrase protected key with non ascii character)
|
2018-10-17 21:29:18 +02:00
|
|
|
shell: "openssl rsa -noout -text -in {{ output_dir }}/privatekey6.pem -passin pass:ànsïblé | grep Private | sed 's/\\(RSA\\s\\)*Private-Key: (\\(.*\\) bit.*)/\\2/'"
|
2017-08-21 13:19:41 +02:00
|
|
|
register: privatekey6
|
2017-11-27 23:58:08 +01:00
|
|
|
when: openssl_version.stdout is version('0.9.8zh', '>=')
|
2017-08-21 13:19:41 +02:00
|
|
|
|
|
|
|
- name: Validate privatekey6 (assert - Passphrase protected key with non ascii character)
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- privatekey6.stdout == '4096'
|
2017-11-27 23:58:08 +01:00
|
|
|
when: openssl_version.stdout is version('0.9.8zh', '>=')
|
2018-12-18 10:07:36 +01:00
|
|
|
|
|
|
|
- name: Validate ECC generation (dump with OpenSSL)
|
|
|
|
shell: "openssl ec -in {{ output_dir }}/privatekey-{{ item.item.curve }}.pem -noout -text | grep 'ASN1 OID: ' | sed 's/ASN1 OID: \\([^ ]*\\)/\\1/'"
|
|
|
|
loop: "{{ privatekey_ecc_generate.results }}"
|
|
|
|
register: privatekey_ecc_dump
|
|
|
|
when: openssl_version.stdout is version('0.9.8zh', '>=') and 'skip_reason' not in item
|
|
|
|
loop_control:
|
|
|
|
label: "{{ item.item.curve }}"
|
|
|
|
|
|
|
|
- name: Validate ECC generation
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- item is changed
|
|
|
|
loop: "{{ privatekey_ecc_generate.results }}"
|
|
|
|
when: "'skip_reason' not in item"
|
|
|
|
loop_control:
|
|
|
|
label: "{{ item.item.curve }}"
|
|
|
|
|
|
|
|
- name: Validate ECC generation (curve type)
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "'skip_reason' in item or item.item.item.openssl_name == item.stdout"
|
|
|
|
loop: "{{ privatekey_ecc_dump.results }}"
|
|
|
|
when: "'skip_reason' not in item"
|
|
|
|
loop_control:
|
|
|
|
label: "{{ item.item.item }} - {{ item.stdout if 'stdout' in item else '<unsupported>' }}"
|
|
|
|
|
|
|
|
- name: Validate ECC generation idempotency
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- item is not changed
|
|
|
|
loop: "{{ privatekey_ecc_idempotency.results }}"
|
|
|
|
when: "'skip_reason' not in item"
|
|
|
|
loop_control:
|
|
|
|
label: "{{ item.item.curve }}"
|