Debian Codegraph @

ansible_collections/community/crypto/plugins/doc_fragments/_module_certificate.py

raw
1 # Copyright (c) 2016-2017, Yanis Guenane <[email protected]>
2 # Copyright (c) 2017, Markus Teufelberger <[email protected]>
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 # Note that this doc fragment is **PRIVATE** to the collection. It can have breaking changes at any time.
7 # Do not use this from other collections or standalone plugins/modules!
8
9 from __future__ import annotations
10
11
12 class ModuleDocFragment:
13 # Standard files documentation fragment
14 DOCUMENTATION = r"""
15 description:
16 - This module allows one to (re)generate OpenSSL certificates.
17 - It uses the cryptography python library to interact with OpenSSL.
18 attributes:
19 diff_mode:
20 support: full
21 idempotent:
22 support: partial
23 details:
24 - If relative timestamps are used and O(ignore_timestamps=false), the module is not idempotent.
25 - The option O(force=true) generally disables idempotency.
26 requirements:
27 - cryptography >= 3.3 (if using V(selfsigned) or V(ownca) provider)
28 options:
29 force:
30 description:
31 - Generate the certificate, even if it already exists.
32 type: bool
33 default: false
34
35 csr_path:
36 description:
37 - Path to the Certificate Signing Request (CSR) used to generate this certificate.
38 - This is mutually exclusive with O(csr_content).
39 type: path
40 csr_content:
41 description:
42 - Content of the Certificate Signing Request (CSR) used to generate this certificate.
43 - This is mutually exclusive with O(csr_path).
44 type: str
45
46 privatekey_path:
47 description:
48 - Path to the private key to use when signing the certificate.
49 - This is mutually exclusive with O(privatekey_content).
50 type: path
51 privatekey_content:
52 description:
53 - Content of the private key to use when signing the certificate.
54 - This is mutually exclusive with O(privatekey_path).
55 type: str
56
57 privatekey_passphrase:
58 description:
59 - The passphrase for the O(privatekey_path) resp. O(privatekey_content).
60 - This is required if the private key is password protected.
61 type: str
62
63 ignore_timestamps:
64 description:
65 - Whether the "not before" and "not after" timestamps should be ignored for idempotency checks.
66 - It is better to keep the default value V(true) when using relative timestamps (like V(+0s) for now).
67 type: bool
68 default: true
69 version_added: 2.0.0
70
71 select_crypto_backend:
72 description:
73 - Determines which crypto backend to use.
74 - The default choice is V(auto), which tries to use C(cryptography) if available.
75 - If set to V(cryptography), will try to use the L(cryptography,https://cryptography.io/) library.
76 - Note that with community.crypto 3.0.0, all values behave the same.
77 This option will be deprecated in a later version.
78 We recommend to not set it explicitly.
79 type: str
80 default: auto
81 choices: [auto, cryptography]
82
83 notes:
84 - All ASN.1 TIME values should be specified following the YYYYMMDDHHMMSSZ pattern.
85 - Date specified should be UTC. Minutes and seconds are mandatory.
86 - For security reason, when you use V(ownca) provider, you should NOT run M(community.crypto.x509_certificate) on a target
87 machine, but on a dedicated CA machine. It is recommended not to store the CA private key on the target machine. Once
88 signed, the certificate can be moved to the target machine.
89 seealso:
90 - module: community.crypto.openssl_csr
91 - module: community.crypto.openssl_csr_pipe
92 - module: community.crypto.openssl_dhparam
93 - module: community.crypto.openssl_pkcs12
94 - module: community.crypto.openssl_privatekey
95 - module: community.crypto.openssl_privatekey_pipe
96 - module: community.crypto.openssl_publickey
97 """
98
99 BACKEND_ACME_DOCUMENTATION = r"""
100 description:
101 - This module allows one to (re)generate OpenSSL certificates.
102 requirements:
103 - acme-tiny >= 4.0.0 (if using the V(acme) provider)
104 options:
105 acme_accountkey_path:
106 description:
107 - The path to the accountkey for the V(acme) provider.
108 - This is only used by the V(acme) provider.
109 type: path
110
111 acme_challenge_path:
112 description:
113 - The path to the ACME challenge directory that is served on U(http://<HOST>:80/.well-known/acme-challenge/)
114 - This is only used by the V(acme) provider.
115 type: path
116
117 acme_chain:
118 description:
119 - Include the intermediate certificate to the generated certificate
120 - This is only used by the V(acme) provider.
121 - Note that this is only available for older versions of C(acme-tiny).
122 New versions include the chain automatically, and setting O(acme_chain) to V(true) results in an error.
123 type: bool
124 default: false
125
126 acme_directory:
127 description:
128 - "The ACME directory to use. You can use any directory that supports the ACME protocol, such as Let's Encrypt."
129 - "Let's Encrypt recommends using their staging server while developing jobs. U(https://letsencrypt.org/docs/staging-environment/)."
130 type: str
131 default: https://acme-v02.api.letsencrypt.org/directory
132 """
133
134 BACKEND_OWNCA_DOCUMENTATION = r"""
135 description:
136 - The V(ownca) provider is intended for generating an OpenSSL certificate signed with your own
137 CA (Certificate Authority) certificate (self-signed certificate).
138 options:
139 ownca_path:
140 description:
141 - Remote absolute path of the CA (Certificate Authority) certificate.
142 - This is only used by the V(ownca) provider.
143 - This is mutually exclusive with O(ownca_content).
144 type: path
145 ownca_content:
146 description:
147 - Content of the CA (Certificate Authority) certificate.
148 - This is only used by the V(ownca) provider.
149 - This is mutually exclusive with O(ownca_path).
150 type: str
151
152 ownca_privatekey_path:
153 description:
154 - Path to the CA (Certificate Authority) private key to use when signing the certificate.
155 - This is only used by the V(ownca) provider.
156 - This is mutually exclusive with O(ownca_privatekey_content).
157 type: path
158 ownca_privatekey_content:
159 description:
160 - Content of the CA (Certificate Authority) private key to use when signing the certificate.
161 - This is only used by the V(ownca) provider.
162 - This is mutually exclusive with O(ownca_privatekey_path).
163 type: str
164
165 ownca_privatekey_passphrase:
166 description:
167 - The passphrase for the O(ownca_privatekey_path) resp. O(ownca_privatekey_content).
168 - This is only used by the V(ownca) provider.
169 type: str
170
171 ownca_digest:
172 description:
173 - The digest algorithm to be used for the V(ownca) certificate.
174 - This is only used by the V(ownca) provider.
175 type: str
176 default: sha256
177
178 ownca_version:
179 description:
180 - The version of the V(ownca) certificate.
181 - Nowadays it should almost always be V(3).
182 - This is only used by the V(ownca) provider.
183 type: int
184 default: 3
185 choices:
186 - 3
187
188 ownca_not_before:
189 description:
190 - The point in time the certificate is valid from.
191 - Time can be specified either as relative time or as absolute timestamp.
192 - Time will always be interpreted as UTC.
193 - Valid format is C([+-]timespec | ASN.1 TIME) where timespec can be an integer
194 + C([w | d | h | m | s]) (for example V(+32w1d2h)).
195 - If this value is not specified, the certificate will start being valid from now.
196 - Note that this value is B(not used to determine whether an existing certificate should be regenerated).
197 This can be changed by setting the O(ignore_timestamps) option to V(false). Please note that you should
198 avoid relative timestamps when setting O(ignore_timestamps=false).
199 - This is only used by the V(ownca) provider.
200 type: str
201 default: +0s
202
203 ownca_not_after:
204 description:
205 - The point in time at which the certificate stops being valid.
206 - Time can be specified either as relative time or as absolute timestamp.
207 - Time will always be interpreted as UTC.
208 - Valid format is C([+-]timespec | ASN.1 TIME) where timespec can be an integer
209 + C([w | d | h | m | s]) (for example V(+32w1d2h)).
210 - If this value is not specified, the certificate will stop being valid 10 years from now.
211 - Note that this value is B(not used to determine whether an existing certificate should be regenerated).
212 This can be changed by setting the O(ignore_timestamps) option to V(false). Please note that you should
213 avoid relative timestamps when setting O(ignore_timestamps=false).
214 - This is only used by the V(ownca) provider.
215 - On macOS 10.15 and onwards, TLS server certificates must have a validity period of 825 days or fewer.
216 Please see U(https://support.apple.com/en-us/HT210176) for more details.
217 type: str
218 default: +3650d
219
220 ownca_create_subject_key_identifier:
221 description:
222 - Whether to create the Subject Key Identifier (SKI) from the public key.
223 - A value of V(create_if_not_provided) (default) only creates a SKI when the CSR does not
224 provide one.
225 - A value of V(always_create) always creates a SKI. If the CSR provides one, that one is
226 ignored.
227 - A value of V(never_create) never creates a SKI. If the CSR provides one, that one is used.
228 - This is only used by the V(ownca) provider.
229 type: str
230 choices: [create_if_not_provided, always_create, never_create]
231 default: create_if_not_provided
232
233 ownca_create_authority_key_identifier:
234 description:
235 - Create a Authority Key Identifier from the CA's certificate. If the CSR provided
236 a authority key identifier, it is ignored.
237 - The Authority Key Identifier is generated from the CA certificate's Subject Key Identifier,
238 if available. If it is not available, the CA certificate's public key will be used.
239 - This is only used by the V(ownca) provider.
240 type: bool
241 default: true
242 """
243
244 BACKEND_SELFSIGNED_DOCUMENTATION = r"""
245 notes:
246 - For the V(selfsigned) provider, O(csr_path) and O(csr_content) are optional. If not provided, a
247 certificate without any information (Subject, Subject Alternative Names, Key Usage, etc.) is created.
248
249 options:
250 # NOTE: descriptions in options are overwritten, not appended. For that reason, the texts provided
251 # here for csr_path and csr_content are not visible to the user. That's why this information is
252 # added to the notes (see above).
253
254 # csr_path:
255 # description:
256 # - This is optional for the V(selfsigned) provider. If not provided, a certificate
257 # without any information (Subject, Subject Alternative Names, Key Usage, etc.) is
258 # created.
259
260 # csr_content:
261 # description:
262 # - This is optional for the V(selfsigned) provider. If not provided, a certificate
263 # without any information (Subject, Subject Alternative Names, Key Usage, etc.) is
264 # created.
265
266 selfsigned_version:
267 description:
268 - Version of the V(selfsigned) certificate.
269 - Nowadays it should almost always be V(3).
270 - This is only used by the V(selfsigned) provider.
271 type: int
272 default: 3
273 choices:
274 - 3
275
276 selfsigned_digest:
277 description:
278 - Digest algorithm to be used when self-signing the certificate.
279 - This is only used by the V(selfsigned) provider.
280 type: str
281 default: sha256
282
283 selfsigned_not_before:
284 description:
285 - The point in time the certificate is valid from.
286 - Time can be specified either as relative time or as absolute timestamp.
287 - Time will always be interpreted as UTC.
288 - Valid format is C([+-]timespec | ASN.1 TIME) where timespec can be an integer
289 + C([w | d | h | m | s]) (for example V(+32w1d2h)).
290 - If this value is not specified, the certificate will start being valid from now.
291 - Note that this value is B(not used to determine whether an existing certificate should be regenerated).
292 This can be changed by setting the O(ignore_timestamps) option to V(false). Please note that you should
293 avoid relative timestamps when setting O(ignore_timestamps=false).
294 - This is only used by the V(selfsigned) provider.
295 type: str
296 default: +0s
297 aliases:
298 - selfsigned_notBefore
299
300 selfsigned_not_after:
301 description:
302 - The point in time at which the certificate stops being valid.
303 - Time can be specified either as relative time or as absolute timestamp.
304 - Time will always be interpreted as UTC.
305 - Valid format is C([+-]timespec | ASN.1 TIME) where timespec can be an integer
306 + C([w | d | h | m | s]) (for example V(+32w1d2h)).
307 - If this value is not specified, the certificate will stop being valid 10 years from now.
308 - Note that this value is B(not used to determine whether an existing certificate should be regenerated).
309 This can be changed by setting the O(ignore_timestamps) option to V(false). Please note that you should
310 avoid relative timestamps when setting O(ignore_timestamps=false).
311 - This is only used by the V(selfsigned) provider.
312 - On macOS 10.15 and onwards, TLS server certificates must have a validity period of 825 days or fewer.
313 Please see U(https://support.apple.com/en-us/HT210176) for more details.
314 type: str
315 default: +3650d
316 aliases:
317 - selfsigned_notAfter
318
319 selfsigned_create_subject_key_identifier:
320 description:
321 - Whether to create the Subject Key Identifier (SKI) from the public key.
322 - A value of V(create_if_not_provided) (default) only creates a SKI when the CSR does not
323 provide one.
324 - A value of V(always_create) always creates a SKI. If the CSR provides one, that one is
325 ignored.
326 - A value of V(never_create) never creates a SKI. If the CSR provides one, that one is used.
327 - This is only used by the V(selfsigned) provider.
328 type: str
329 choices: [create_if_not_provided, always_create, never_create]
330 default: create_if_not_provided
331 """