mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
caf7fd2245
* Raise OpenSSLBadPassphraseError if passphrase is wrong. * Improve handling of passphrase errors. Current behavior for modules is: if passphrase is wrong (or wrongly specified), fail. Current behavior for openssl_privatekey is: if passphrase is worng (or wrongly specified), regenerate. * Add changelog. * Add tests. * Adjustments for some versions of PyOpenSSL. * Update lib/ansible/modules/crypto/openssl_certificate.py Improve text. Co-Authored-By: felixfontein <felix@fontein.de>
94 lines
3.4 KiB
YAML
94 lines
3.4 KiB
YAML
---
|
|
- name: Validate certificate (test - privatekey modulus)
|
|
shell: 'openssl rsa -noout -modulus -in {{ output_dir }}/privatekey.pem'
|
|
register: privatekey_modulus
|
|
|
|
- name: Validate certificate (test - certificate modulus)
|
|
shell: 'openssl x509 -noout -modulus -in {{ output_dir }}/cert.pem'
|
|
register: cert_modulus
|
|
|
|
- name: Validate certificate (test - issuer value)
|
|
shell: 'openssl x509 -noout -in {{ output_dir}}/cert.pem -text | grep "Issuer" | sed "s/.*: \(.*\)/\1/g; s/ //g;"'
|
|
register: cert_issuer
|
|
|
|
|
|
- name: Validate certificate (test - certficate version == default == 3)
|
|
shell: 'openssl x509 -noout -in {{ output_dir}}/cert.pem -text | grep "Version" | sed "s/.*: \(.*\) .*/\1/g"'
|
|
register: cert_version
|
|
|
|
- name: Validate certificate (assert)
|
|
assert:
|
|
that:
|
|
- cert_modulus.stdout == privatekey_modulus.stdout
|
|
- cert_version.stdout == '3'
|
|
- cert_issuer.stdout == 'CN=www.example.com'
|
|
|
|
- name: Validate certificate idempotence
|
|
assert:
|
|
that:
|
|
- selfsigned_certificate.serial_number == selfsigned_certificate_idempotence.serial_number
|
|
- selfsigned_certificate.notBefore == selfsigned_certificate_idempotence.notBefore
|
|
- selfsigned_certificate.notAfter == selfsigned_certificate_idempotence.notAfter
|
|
|
|
- name: Validate certificate v2 (test - certificate version == 2)
|
|
shell: 'openssl x509 -noout -in {{ output_dir}}/cert_v2.pem -text | grep "Version" | sed "s/.*: \(.*\) .*/\1/g"'
|
|
register: cert_v2_version
|
|
|
|
- name: Validate certificate version 2 (assert)
|
|
assert:
|
|
that:
|
|
- cert_v2_version.stdout == '2'
|
|
|
|
- name: Validate certificate2 (test - privatekey modulus)
|
|
shell: 'openssl rsa -noout -modulus -in {{ output_dir }}/privatekey2.pem'
|
|
register: privatekey2_modulus
|
|
|
|
- name: Validate certificate2 (test - certificate modulus)
|
|
shell: 'openssl x509 -noout -modulus -in {{ output_dir }}/cert2.pem'
|
|
register: cert2_modulus
|
|
|
|
- name: Validate certificate2 (assert)
|
|
assert:
|
|
that:
|
|
- cert2_modulus.stdout == privatekey2_modulus.stdout
|
|
|
|
- name: Validate certificate3 (test - notBefore)
|
|
shell: 'openssl x509 -noout -in {{ output_dir }}/cert3.pem -text | grep "Not Before" | sed "s/.*: \(.*\) .*/\1/g"'
|
|
register: cert3_notBefore
|
|
|
|
- name: Validate certificate3 (test - notAfter)
|
|
shell: 'openssl x509 -noout -in {{ output_dir }}/cert3.pem -text | grep "Not After" | sed "s/.*: \(.*\) .*/\1/g"'
|
|
register: cert3_notAfter
|
|
|
|
- name: Validate certificate3 (assert - notBefore)
|
|
assert:
|
|
that:
|
|
- cert3_notBefore.stdout == 'Oct 23 13:37:42 2018'
|
|
|
|
- name: Validate certificate3 (assert - notAfter)
|
|
assert:
|
|
that:
|
|
- cert3_notAfter.stdout == 'Oct 23 13:37:42 2019'
|
|
|
|
- name: Validate ECC certificate (test - privatekey's pubkey)
|
|
shell: 'openssl ec -pubout -in {{ output_dir }}/privatekey_ecc.pem'
|
|
register: privatekey_ecc_pubkey
|
|
|
|
- name: Validate ECC certificate (test - certificate pubkey)
|
|
shell: 'openssl x509 -noout -pubkey -in {{ output_dir }}/cert_ecc.pem'
|
|
register: cert_ecc_pubkey
|
|
|
|
- name: Validate ECC certificate (assert)
|
|
assert:
|
|
that:
|
|
- cert_ecc_pubkey.stdout == privatekey_ecc_pubkey.stdout
|
|
|
|
- name:
|
|
assert:
|
|
that:
|
|
- passphrase_error_1 is failed
|
|
- "'assphrase' in passphrase_error_1.msg or 'assword' in passphrase_error_1.msg"
|
|
- passphrase_error_2 is failed
|
|
- "'assphrase' in passphrase_error_1.msg or 'assword' in passphrase_error_2.msg"
|
|
- passphrase_error_3 is failed
|
|
- "'assphrase' in passphrase_error_1.msg or 'assword' in passphrase_error_3.msg"
|