Debian Codegraph @

ansible_collections/community/crypto/tests/integration/targets/x509_certificate_convert/tasks/main.yml

raw
1 ---
2 # Copyright (c) Ansible Project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 ####################################################################
7 # WARNING: These are designed specifically for Ansible tests #
8 # and should not be used as examples of how to write Ansible roles #
9 ####################################################################
10
11 - name: Make sure the Python idna library is installed
12 ansible.builtin.pip:
13 name: idna
14 state: present
15
16 - name: Generate privatekey
17 community.crypto.openssl_privatekey:
18 path: '{{ remote_tmp_dir }}/privatekey.pem'
19 size: '{{ default_rsa_key_size_certificates }}'
20
21 - name: Generate CSR 1
22 community.crypto.openssl_csr:
23 path: '{{ remote_tmp_dir }}/csr_1.csr'
24 privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem'
25 subject:
26 commonName: www.example.com
27 C: de
28 L: Somewhere
29 ST: Zurich
30 streetAddress: Welcome Street
31 O: Ansible
32 organizationalUnitName:
33 - Crypto Department
34 - ACME Department
35 serialNumber: "1234"
36 SN: Last Name
37 GN: First Name
38 title: Chief
39 pseudonym: test
40 UID: asdf
41 emailAddress: [email protected]
42 postalAddress: 1234 Somewhere
43 postalCode: "1234"
44 useCommonNameForSAN: false
45 key_usage:
46 - digitalSignature
47 - keyAgreement
48 - Non Repudiation
49 - Key Encipherment
50 - dataEncipherment
51 - Certificate Sign
52 - cRLSign
53 - Encipher Only
54 - decipherOnly
55 key_usage_critical: true
56 extended_key_usage:
57 - serverAuth # the same as "TLS Web Server Authentication"
58 - TLS Web Server Authentication
59 - TLS Web Client Authentication
60 - Code Signing
61 - E-mail Protection
62 - timeStamping
63 - OCSPSigning
64 - Any Extended Key Usage
65 - qcStatements
66 - DVCS
67 - IPSec User
68 - biometricInfo
69 subject_alt_name:
70 - "DNS:www.ansible.com"
71 - "DNS:öç.com"
72 # cryptography < 2.1 cannot handle certain Unicode characters
73 - "DNS:☺.com"
74 - "IP:1.2.3.4"
75 - "IP:::1"
76 - "email:[email protected]"
77 - "URI:https://example.org/test/index.html"
78 basic_constraints:
79 - "CA:TRUE"
80 - "pathlen:23"
81 basic_constraints_critical: true
82 ocsp_must_staple: true
83 subject_key_identifier: "00:11:22:33"
84 authority_key_identifier: "44:55:66:77"
85 authority_cert_issuer: '{{ value_for_authority_cert_issuer }}'
86 authority_cert_serial_number: 12345
87 vars:
88 value_for_authority_cert_issuer:
89 - "DNS:ca.example.org"
90 - "IP:1.2.3.4"
91
92 - name: Generate CSR 2
93 community.crypto.openssl_csr:
94 path: '{{ remote_tmp_dir }}/csr_2.csr'
95 privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem'
96 useCommonNameForSAN: false
97 basic_constraints:
98 - "CA:TRUE"
99
100 - name: Generate CSR 3
101 community.crypto.openssl_csr:
102 path: '{{ remote_tmp_dir }}/csr_3.csr'
103 privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem'
104 useCommonNameForSAN: false
105 subject_alt_name:
106 - "DNS:*.ansible.com"
107 - "DNS:*.example.org"
108 - "IP:DEAD:BEEF::1"
109 basic_constraints:
110 - "CA:FALSE"
111 authority_cert_issuer: '{{ value_for_authority_cert_issuer }}'
112 authority_cert_serial_number: 12345
113 vars:
114 value_for_authority_cert_issuer:
115 - "DNS:ca.example.org"
116 - "IP:1.2.3.4"
117
118 - name: Generate selfsigned certificates
119 community.crypto.x509_certificate:
120 path: '{{ remote_tmp_dir }}/cert_{{ item }}.pem'
121 csr_path: '{{ remote_tmp_dir }}/csr_{{ item }}.csr'
122 privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem'
123 provider: selfsigned
124 selfsigned_digest: sha256
125 selfsigned_not_after: "+10d"
126 selfsigned_not_before: "-3d"
127 loop:
128 - 1
129 - 2
130 - 3
131
132 - name: Convert PEM files to DER
133 ansible.builtin.command:
134 cmd: openssl x509 -inform PEM -outform DER -in {{ remote_tmp_dir }}/cert_{{ item }}.pem -out {{ remote_tmp_dir }}/cert_{{ item }}.der
135 loop:
136 - 1
137 - 2
138 - 3
139
140 - name: Running tests
141 ansible.builtin.include_tasks: impl.yml