mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
36a790dcde
* New cryptography backend for openssl_certificate load_* functions in module_utils/crypto.py now have a backend paramter which when set to 'cryptography' will return cryptography objects so they can be used for both pyopenssl and cryptography backends. Added a select_message_digest function too returning a cryptography digest hash from `cryptography.hazmat.primitives.hashes` Added new classes for Cryptography backend * Run test with various backends. * Prefixing tests. * Make sure we have the correct backend available. * Linting (flake8). * Moved cryptography import to separate try/except * Make sure certificate is actually valid at some time in the past. * Improve error handling. * Trying to fix validation for cryptography backend. * Fixed issue with keyUsage test in assertonly * Fixed CI/Lint issues * Fix private key problem for OwnCA. * Cryptography backend doesn't support v2 certs. * issue an expired cert with command when using cryptography backend * Added warning when backend is auto and v2 cert is requested * Bumped min cryptography version to 1.6 * Correctly check for failure when backend is cryptography and cert is v2 * Use self.backend where possible * Use secp521r1 EC when testing on CentOS6 * Fixed pylint issue * AcmeCertificate support for both backends * Review fixes * Fixed missing '(' when raising error * Fixed date_fmt loop * Updated docs and requirements with cryptography * Add openssl_certificate to changelog.
205 lines
7.4 KiB
YAML
205 lines
7.4 KiB
YAML
---
|
|
- name: (OwnCA, {{select_crypto_backend}}) Generate CA privatekey
|
|
openssl_privatekey:
|
|
path: '{{ output_dir }}/ca_privatekey.pem'
|
|
|
|
- name: (OwnCA, {{select_crypto_backend}}) Generate CA CSR
|
|
openssl_csr:
|
|
path: '{{ output_dir }}/ca_csr.csr'
|
|
privatekey_path: '{{ output_dir }}/ca_privatekey.pem'
|
|
subject:
|
|
commonName: Example CA
|
|
useCommonNameForSAN: no
|
|
basic_constraints:
|
|
- 'CA:TRUE'
|
|
basic_constraints_critical: yes
|
|
|
|
- name: (OwnCA, {{select_crypto_backend}}) Generate selfsigned CA certificate
|
|
openssl_certificate:
|
|
path: '{{ output_dir }}/ca_cert.pem'
|
|
csr_path: '{{ output_dir }}/ca_csr.csr'
|
|
privatekey_path: '{{ output_dir }}/ca_privatekey.pem'
|
|
provider: selfsigned
|
|
selfsigned_digest: sha256
|
|
select_crypto_backend: '{{ select_crypto_backend }}'
|
|
|
|
- name: (OwnCA, {{select_crypto_backend}}) Generate ownca certificate
|
|
openssl_certificate:
|
|
path: '{{ output_dir }}/ownca_cert.pem'
|
|
csr_path: '{{ output_dir }}/csr.csr'
|
|
privatekey_path: '{{ output_dir }}/privatekey.pem'
|
|
ownca_path: '{{ output_dir }}/ca_cert.pem'
|
|
ownca_privatekey_path: '{{ output_dir }}/ca_privatekey.pem'
|
|
provider: ownca
|
|
ownca_digest: sha256
|
|
select_crypto_backend: '{{ select_crypto_backend }}'
|
|
register: ownca_certificate
|
|
|
|
- name: (OwnCA, {{select_crypto_backend}}) Generate ownca certificate
|
|
openssl_certificate:
|
|
path: '{{ output_dir }}/ownca_cert.pem'
|
|
csr_path: '{{ output_dir }}/csr.csr'
|
|
privatekey_path: '{{ output_dir }}/privatekey.pem'
|
|
ownca_path: '{{ output_dir }}/ca_cert.pem'
|
|
ownca_privatekey_path: '{{ output_dir }}/ca_privatekey.pem'
|
|
provider: ownca
|
|
ownca_digest: sha256
|
|
select_crypto_backend: '{{ select_crypto_backend }}'
|
|
register: ownca_certificate_idempotence
|
|
|
|
- name: (OwnCA, {{select_crypto_backend}}) Generate ownca certificate (check mode)
|
|
openssl_certificate:
|
|
path: '{{ output_dir }}/ownca_cert.pem'
|
|
csr_path: '{{ output_dir }}/csr.csr'
|
|
privatekey_path: '{{ output_dir }}/privatekey.pem'
|
|
ownca_path: '{{ output_dir }}/ca_cert.pem'
|
|
ownca_privatekey_path: '{{ output_dir }}/ca_privatekey.pem'
|
|
provider: ownca
|
|
ownca_digest: sha256
|
|
select_crypto_backend: '{{ select_crypto_backend }}'
|
|
check_mode: yes
|
|
|
|
- name: (OwnCA, {{select_crypto_backend}}) Check ownca certificate
|
|
openssl_certificate:
|
|
path: '{{ output_dir }}/ownca_cert.pem'
|
|
privatekey_path: '{{ output_dir }}/privatekey.pem'
|
|
provider: assertonly
|
|
has_expired: False
|
|
version: 3
|
|
signature_algorithms:
|
|
- sha256WithRSAEncryption
|
|
- sha256WithECDSAEncryption
|
|
subject:
|
|
commonName: www.example.com
|
|
issuer:
|
|
commonName: Example CA
|
|
select_crypto_backend: '{{ select_crypto_backend }}'
|
|
|
|
- name: (OwnCA, {{select_crypto_backend}}) Generate ownca v2 certificate
|
|
openssl_certificate:
|
|
path: '{{ output_dir }}/ownca_cert_v2.pem'
|
|
csr_path: '{{ output_dir }}/csr.csr'
|
|
privatekey_path: '{{ output_dir }}/privatekey.pem'
|
|
ownca_path: '{{ output_dir }}/ca_cert.pem'
|
|
ownca_privatekey_path: '{{ output_dir }}/ca_privatekey.pem'
|
|
provider: ownca
|
|
ownca_digest: sha256
|
|
ownca_version: 2
|
|
select_crypto_backend: '{{ select_crypto_backend }}'
|
|
register: ownca_v2_certificate
|
|
ignore_errors: true
|
|
|
|
- name: (OwnCA, {{select_crypto_backend}}) Generate ownca certificate2
|
|
openssl_certificate:
|
|
path: '{{ output_dir }}/ownca_cert2.pem'
|
|
csr_path: '{{ output_dir }}/csr2.csr'
|
|
privatekey_path: '{{ output_dir }}/privatekey2.pem'
|
|
ownca_path: '{{ output_dir }}/ca_cert.pem'
|
|
ownca_privatekey_path: '{{ output_dir }}/ca_privatekey.pem'
|
|
provider: ownca
|
|
ownca_digest: sha256
|
|
select_crypto_backend: '{{ select_crypto_backend }}'
|
|
|
|
- name: (OwnCA, {{select_crypto_backend}}) Check ownca certificate2
|
|
openssl_certificate:
|
|
path: '{{ output_dir }}/ownca_cert2.pem'
|
|
privatekey_path: '{{ output_dir }}/privatekey2.pem'
|
|
provider: assertonly
|
|
has_expired: False
|
|
version: 3
|
|
signature_algorithms:
|
|
- sha256WithRSAEncryption
|
|
- sha256WithECDSAEncryption
|
|
subject:
|
|
commonName: www.example.com
|
|
C: US
|
|
ST: California
|
|
L: Los Angeles
|
|
O: ACME Inc.
|
|
OU:
|
|
- Roadrunner pest control
|
|
- Pyrotechnics
|
|
keyUsage:
|
|
- digitalSignature
|
|
extendedKeyUsage:
|
|
- ipsecUser
|
|
- biometricInfo
|
|
issuer:
|
|
commonName: Example CA
|
|
select_crypto_backend: '{{ select_crypto_backend }}'
|
|
|
|
- name: (OwnCA, {{select_crypto_backend}}) Create ownca certificate with notBefore and notAfter
|
|
openssl_certificate:
|
|
provider: ownca
|
|
ownca_not_before: 20181023133742Z
|
|
ownca_not_after: 20191023133742Z
|
|
path: "{{ output_dir }}/ownca_cert3.pem"
|
|
csr_path: "{{ output_dir }}/csr.csr"
|
|
privatekey_path: "{{ output_dir }}/privatekey3.pem"
|
|
ownca_path: '{{ output_dir }}/ca_cert.pem'
|
|
ownca_privatekey_path: '{{ output_dir }}/ca_privatekey.pem'
|
|
select_crypto_backend: '{{ select_crypto_backend }}'
|
|
|
|
- name: (OwnCA, {{select_crypto_backend}}) Create ownca certificate with relative notBefore and notAfter
|
|
openssl_certificate:
|
|
provider: ownca
|
|
ownca_not_before: +1s
|
|
ownca_not_after: +52w
|
|
path: "{{ output_dir }}/ownca_cert4.pem"
|
|
csr_path: "{{ output_dir }}/csr.csr"
|
|
privatekey_path: "{{ output_dir }}/privatekey3.pem"
|
|
ownca_path: '{{ output_dir }}/ca_cert.pem'
|
|
ownca_privatekey_path: '{{ output_dir }}/ca_privatekey.pem'
|
|
select_crypto_backend: '{{ select_crypto_backend }}'
|
|
|
|
- name: (OwnCA, {{select_crypto_backend}}) Generate ownca ECC certificate
|
|
openssl_certificate:
|
|
path: '{{ output_dir }}/ownca_cert_ecc.pem'
|
|
csr_path: '{{ output_dir }}/csr_ecc.csr'
|
|
privatekey_path: '{{ output_dir }}/privatekey_ecc.pem'
|
|
ownca_path: '{{ output_dir }}/ca_cert.pem'
|
|
ownca_privatekey_path: '{{ output_dir }}/ca_privatekey.pem'
|
|
provider: ownca
|
|
ownca_digest: sha256
|
|
select_crypto_backend: '{{ select_crypto_backend }}'
|
|
register: ownca_certificate_ecc
|
|
|
|
- name: (OwnCA, {{select_crypto_backend}}) Generate ownca certificate (failed passphrase 1)
|
|
openssl_certificate:
|
|
path: '{{ output_dir }}/ownca_cert_pw1.pem'
|
|
csr_path: '{{ output_dir }}/csr_ecc.csr'
|
|
ownca_path: '{{ output_dir }}/ca_cert.pem'
|
|
ownca_privatekey_path: '{{ output_dir }}/ca_privatekey.pem'
|
|
ownca_privatekey_passphrase: hunter2
|
|
provider: ownca
|
|
ownca_digest: sha256
|
|
select_crypto_backend: '{{ select_crypto_backend }}'
|
|
ignore_errors: yes
|
|
register: passphrase_error_1
|
|
|
|
- name: (OwnCA, {{select_crypto_backend}}) Generate ownca certificate (failed passphrase 2)
|
|
openssl_certificate:
|
|
path: '{{ output_dir }}/ownca_cert_pw1.pem'
|
|
csr_path: '{{ output_dir }}/csr_ecc.csr'
|
|
ownca_path: '{{ output_dir }}/ca_cert.pem'
|
|
ownca_privatekey_path: '{{ output_dir }}/privatekeypw.pem'
|
|
ownca_privatekey_passphrase: wrong_password
|
|
provider: ownca
|
|
ownca_digest: sha256
|
|
select_crypto_backend: '{{ select_crypto_backend }}'
|
|
ignore_errors: yes
|
|
register: passphrase_error_2
|
|
|
|
- name: (OwnCA, {{select_crypto_backend}}) Generate ownca certificate (failed passphrase 3)
|
|
openssl_certificate:
|
|
path: '{{ output_dir }}/ownca_cert_pw3.pem'
|
|
csr_path: '{{ output_dir }}/csr_ecc.csr'
|
|
ownca_path: '{{ output_dir }}/ca_cert.pem'
|
|
ownca_privatekey_path: '{{ output_dir }}/privatekeypw.pem'
|
|
provider: ownca
|
|
ownca_digest: sha256
|
|
select_crypto_backend: '{{ select_crypto_backend }}'
|
|
ignore_errors: yes
|
|
register: passphrase_error_3
|
|
|
|
- import_tasks: ../tests/validate_ownca.yml
|