| 1 |
# Copyright (c) 2017, Yanis Guenane <[email protected]> |
| 2 |
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 3 |
# SPDX-License-Identifier: GPL-3.0-or-later |
| 4 |
|
| 5 |
# Note that this doc fragment is **PRIVATE** to the collection. It can have breaking changes at any time. |
| 6 |
# Do not use this from other collections or standalone plugins/modules! |
| 7 |
|
| 8 |
from __future__ import annotations |
| 9 |
|
| 10 |
|
| 11 |
class ModuleDocFragment: |
| 12 |
# Standard files documentation fragment |
| 13 |
DOCUMENTATION = r""" |
| 14 |
description: |
| 15 |
- This module allows one to (re)generate OpenSSL certificate signing requests. |
| 16 |
- This module supports the subjectAltName, keyUsage, extendedKeyUsage, basicConstraints and OCSP Must Staple extensions. |
| 17 |
attributes: |
| 18 |
diff_mode: |
| 19 |
support: full |
| 20 |
idempotent: |
| 21 |
support: full |
| 22 |
requirements: |
| 23 |
- cryptography >= 3.3 |
| 24 |
options: |
| 25 |
digest: |
| 26 |
description: |
| 27 |
- The digest used when signing the certificate signing request with the private key. |
| 28 |
type: str |
| 29 |
default: sha256 |
| 30 |
privatekey_path: |
| 31 |
description: |
| 32 |
- The path to the private key to use when signing the certificate signing request. |
| 33 |
- Either O(privatekey_path) or O(privatekey_content) must be specified if O(state) is V(present), but not both. |
| 34 |
type: path |
| 35 |
privatekey_content: |
| 36 |
description: |
| 37 |
- The content of the private key to use when signing the certificate signing request. |
| 38 |
- Either O(privatekey_path) or O(privatekey_content) must be specified if O(state) is V(present), but not both. |
| 39 |
type: str |
| 40 |
privatekey_passphrase: |
| 41 |
description: |
| 42 |
- The passphrase for the private key. |
| 43 |
- This is required if the private key is password protected. |
| 44 |
type: str |
| 45 |
version: |
| 46 |
description: |
| 47 |
- The version of the certificate signing request. |
| 48 |
- The only allowed value according to L(RFC 2986,https://tools.ietf.org/html/rfc2986#section-4.1) is 1. |
| 49 |
- This option no longer accepts unsupported values since community.crypto 2.0.0. |
| 50 |
type: int |
| 51 |
default: 1 |
| 52 |
choices: |
| 53 |
- 1 |
| 54 |
subject: |
| 55 |
description: |
| 56 |
- Key/value pairs that will be present in the subject name field of the certificate signing request. |
| 57 |
- If you need to specify more than one value with the same key, use a list as value. |
| 58 |
- If the order of the components is important, use O(subject_ordered). |
| 59 |
- Mutually exclusive with O(subject_ordered). |
| 60 |
type: dict |
| 61 |
subject_ordered: |
| 62 |
description: |
| 63 |
- A list of dictionaries, where every dictionary must contain one key/value pair. This key/value pair will be present |
| 64 |
in the subject name field of the certificate signing request. |
| 65 |
- If you want to specify more than one value with the same key in a row, you can use a list as value. |
| 66 |
- Mutually exclusive with O(subject), and any other subject field option, such as O(country_name), O(state_or_province_name), |
| 67 |
O(locality_name), O(organization_name), O(organizational_unit_name), O(common_name), or O(email_address). |
| 68 |
type: list |
| 69 |
elements: dict |
| 70 |
version_added: 2.0.0 |
| 71 |
country_name: |
| 72 |
description: |
| 73 |
- The countryName field of the certificate signing request subject. |
| 74 |
type: str |
| 75 |
aliases: |
| 76 |
- C |
| 77 |
- countryName |
| 78 |
state_or_province_name: |
| 79 |
description: |
| 80 |
- The stateOrProvinceName field of the certificate signing request subject. |
| 81 |
type: str |
| 82 |
aliases: |
| 83 |
- ST |
| 84 |
- stateOrProvinceName |
| 85 |
locality_name: |
| 86 |
description: |
| 87 |
- The localityName field of the certificate signing request subject. |
| 88 |
type: str |
| 89 |
aliases: |
| 90 |
- L |
| 91 |
- localityName |
| 92 |
organization_name: |
| 93 |
description: |
| 94 |
- The organizationName field of the certificate signing request subject. |
| 95 |
type: str |
| 96 |
aliases: |
| 97 |
- O |
| 98 |
- organizationName |
| 99 |
organizational_unit_name: |
| 100 |
description: |
| 101 |
- The organizationalUnitName field of the certificate signing request subject. |
| 102 |
type: str |
| 103 |
aliases: |
| 104 |
- OU |
| 105 |
- organizationalUnitName |
| 106 |
common_name: |
| 107 |
description: |
| 108 |
- The commonName field of the certificate signing request subject. |
| 109 |
type: str |
| 110 |
aliases: |
| 111 |
- CN |
| 112 |
- commonName |
| 113 |
email_address: |
| 114 |
description: |
| 115 |
- The emailAddress field of the certificate signing request subject. |
| 116 |
type: str |
| 117 |
aliases: |
| 118 |
- E |
| 119 |
- emailAddress |
| 120 |
subject_alt_name: |
| 121 |
description: |
| 122 |
- Subject Alternative Name (SAN) extension to attach to the certificate signing request. |
| 123 |
- Values must be prefixed by their options. (These are C(email), C(URI), C(DNS), C(RID), C(IP), C(dirName), C(otherName), |
| 124 |
and the ones specific to your CA). |
| 125 |
- Note that if no SAN is specified, but a common name, the common name will be added as a SAN except if O(use_common_name_for_san) |
| 126 |
is set to V(false). |
| 127 |
- More at U(https://tools.ietf.org/html/rfc5280#section-4.2.1.6). |
| 128 |
type: list |
| 129 |
elements: str |
| 130 |
aliases: |
| 131 |
- subjectAltName |
| 132 |
subject_alt_name_critical: |
| 133 |
description: |
| 134 |
- Should the subjectAltName extension be considered as critical. |
| 135 |
type: bool |
| 136 |
default: false |
| 137 |
aliases: |
| 138 |
- subjectAltName_critical |
| 139 |
use_common_name_for_san: |
| 140 |
description: |
| 141 |
- If set to V(true), the module will fill the common name in for O(subject_alt_name) with C(DNS:) prefix if no SAN is |
| 142 |
specified. |
| 143 |
type: bool |
| 144 |
default: true |
| 145 |
aliases: |
| 146 |
- useCommonNameForSAN |
| 147 |
key_usage: |
| 148 |
description: |
| 149 |
- This defines the purpose (for example encipherment, signature, certificate signing) of the key contained in the certificate. |
| 150 |
type: list |
| 151 |
elements: str |
| 152 |
aliases: |
| 153 |
- keyUsage |
| 154 |
key_usage_critical: |
| 155 |
description: |
| 156 |
- Should the keyUsage extension be considered as critical. |
| 157 |
type: bool |
| 158 |
default: false |
| 159 |
aliases: |
| 160 |
- keyUsage_critical |
| 161 |
extended_key_usage: |
| 162 |
description: |
| 163 |
- Additional restrictions (for example client authentication, server authentication) on the allowed purposes for which |
| 164 |
the public key may be used. |
| 165 |
type: list |
| 166 |
elements: str |
| 167 |
aliases: |
| 168 |
- extKeyUsage |
| 169 |
- extendedKeyUsage |
| 170 |
extended_key_usage_critical: |
| 171 |
description: |
| 172 |
- Should the extkeyUsage extension be considered as critical. |
| 173 |
type: bool |
| 174 |
default: false |
| 175 |
aliases: |
| 176 |
- extKeyUsage_critical |
| 177 |
- extendedKeyUsage_critical |
| 178 |
basic_constraints: |
| 179 |
description: |
| 180 |
- Indicates basic constraints, such as if the certificate is a CA. |
| 181 |
type: list |
| 182 |
elements: str |
| 183 |
aliases: |
| 184 |
- basicConstraints |
| 185 |
basic_constraints_critical: |
| 186 |
description: |
| 187 |
- Should the basicConstraints extension be considered as critical. |
| 188 |
type: bool |
| 189 |
default: false |
| 190 |
aliases: |
| 191 |
- basicConstraints_critical |
| 192 |
ocsp_must_staple: |
| 193 |
description: |
| 194 |
- Indicates that the certificate should contain the OCSP Must Staple extension (U(https://tools.ietf.org/html/rfc7633)). |
| 195 |
type: bool |
| 196 |
default: false |
| 197 |
aliases: |
| 198 |
- ocspMustStaple |
| 199 |
ocsp_must_staple_critical: |
| 200 |
description: |
| 201 |
- Should the OCSP Must Staple extension be considered as critical. |
| 202 |
- Note that according to the RFC, this extension should not be marked as critical, as old clients not knowing about |
| 203 |
OCSP Must Staple are required to reject such certificates (see U(https://tools.ietf.org/html/rfc7633#section-4)). |
| 204 |
type: bool |
| 205 |
default: false |
| 206 |
aliases: |
| 207 |
- ocspMustStaple_critical |
| 208 |
name_constraints_permitted: |
| 209 |
description: |
| 210 |
- For CA certificates, this specifies a list of identifiers which describe subtrees of names that this CA is allowed |
| 211 |
to issue certificates for. |
| 212 |
- Values must be prefixed by their options. (That is, C(email), C(URI), C(DNS), C(RID), C(IP), C(dirName), C(otherName), |
| 213 |
and the ones specific to your CA). |
| 214 |
type: list |
| 215 |
elements: str |
| 216 |
name_constraints_excluded: |
| 217 |
description: |
| 218 |
- For CA certificates, this specifies a list of identifiers which describe subtrees of names that this CA is B(not) |
| 219 |
allowed to issue certificates for. |
| 220 |
- Values must be prefixed by their options. (That is, C(email), C(URI), C(DNS), C(RID), C(IP), C(dirName), C(otherName), |
| 221 |
and the ones specific to your CA). |
| 222 |
type: list |
| 223 |
elements: str |
| 224 |
name_constraints_critical: |
| 225 |
description: |
| 226 |
- Should the Name Constraints extension be considered as critical. |
| 227 |
type: bool |
| 228 |
default: false |
| 229 |
select_crypto_backend: |
| 230 |
description: |
| 231 |
- Determines which crypto backend to use. |
| 232 |
- The default choice is V(auto), which tries to use C(cryptography) if available. |
| 233 |
- If set to V(cryptography), will try to use the L(cryptography,https://cryptography.io/) library. |
| 234 |
- Note that with community.crypto 3.0.0, all values behave the same. |
| 235 |
This option will be deprecated in a later version. |
| 236 |
We recommend to not set it explicitly. |
| 237 |
type: str |
| 238 |
default: auto |
| 239 |
choices: [auto, cryptography] |
| 240 |
create_subject_key_identifier: |
| 241 |
description: |
| 242 |
- Create the Subject Key Identifier from the public key. |
| 243 |
- Please note that commercial CAs can ignore the value, respectively use a value of their own choice instead. Specifying |
| 244 |
this option is mostly useful for self-signed certificates or for own CAs. |
| 245 |
type: bool |
| 246 |
default: false |
| 247 |
subject_key_identifier: |
| 248 |
description: |
| 249 |
- The subject key identifier as a hex string, where two bytes are separated by colons. |
| 250 |
- 'Example: V(00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33).' |
| 251 |
- Please note that commercial CAs ignore this value, respectively use a value of their own choice. Specifying this option |
| 252 |
is mostly useful for self-signed certificates or for own CAs. |
| 253 |
- Note that this option can only be used if O(create_subject_key_identifier) is V(false). |
| 254 |
type: str |
| 255 |
authority_key_identifier: |
| 256 |
description: |
| 257 |
- The authority key identifier as a hex string, where two bytes are separated by colons. |
| 258 |
- 'Example: V(00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33).' |
| 259 |
- Please note that commercial CAs ignore this value, respectively use a value of their own choice. Specifying this option |
| 260 |
is mostly useful for self-signed certificates or for own CAs. |
| 261 |
- The C(AuthorityKeyIdentifier) extension will only be added if at least one of O(authority_key_identifier), O(authority_cert_issuer) |
| 262 |
and O(authority_cert_serial_number) is specified. |
| 263 |
type: str |
| 264 |
authority_cert_issuer: |
| 265 |
description: |
| 266 |
- Names that will be present in the authority cert issuer field of the certificate signing request. |
| 267 |
- Values must be prefixed by their options. (That is, C(email), C(URI), C(DNS), C(RID), C(IP), C(dirName), C(otherName), |
| 268 |
and the ones specific to your CA). |
| 269 |
- 'Example: V(DNS:ca.example.org).' |
| 270 |
- If specified, O(authority_cert_serial_number) must also be specified. |
| 271 |
- Please note that commercial CAs ignore this value, respectively use a value of their own choice. Specifying this option |
| 272 |
is mostly useful for self-signed certificates or for own CAs. |
| 273 |
- The C(AuthorityKeyIdentifier) extension will only be added if at least one of O(authority_key_identifier), O(authority_cert_issuer) |
| 274 |
and O(authority_cert_serial_number) is specified. |
| 275 |
type: list |
| 276 |
elements: str |
| 277 |
authority_cert_serial_number: |
| 278 |
description: |
| 279 |
- The authority cert serial number. |
| 280 |
- If specified, O(authority_cert_issuer) must also be specified. |
| 281 |
- Please note that commercial CAs ignore this value, respectively use a value of their own choice. Specifying this option |
| 282 |
is mostly useful for self-signed certificates or for own CAs. |
| 283 |
- The C(AuthorityKeyIdentifier) extension will only be added if at least one of O(authority_key_identifier), O(authority_cert_issuer) |
| 284 |
and O(authority_cert_serial_number) is specified. |
| 285 |
- This option accepts an B(integer). If you want to provide serial numbers as colon-separated hex strings, such as C(11:22:33), |
| 286 |
you need to convert them to an integer with P(community.crypto.parse_serial#filter). |
| 287 |
type: int |
| 288 |
crl_distribution_points: |
| 289 |
description: |
| 290 |
- Allows to specify one or multiple CRL distribution points. |
| 291 |
type: list |
| 292 |
elements: dict |
| 293 |
suboptions: |
| 294 |
full_name: |
| 295 |
description: |
| 296 |
- Describes how the CRL can be retrieved. |
| 297 |
- Mutually exclusive with O(crl_distribution_points[].relative_name). |
| 298 |
- 'Example: V(URI:https://ca.example.com/revocations.crl).' |
| 299 |
type: list |
| 300 |
elements: str |
| 301 |
relative_name: |
| 302 |
description: |
| 303 |
- Describes how the CRL can be retrieved relative to the CRL issuer. |
| 304 |
- Mutually exclusive with O(crl_distribution_points[].full_name). |
| 305 |
- 'Example: V(/CN=example.com).' |
| 306 |
type: list |
| 307 |
elements: str |
| 308 |
crl_issuer: |
| 309 |
description: |
| 310 |
- Information about the issuer of the CRL. |
| 311 |
type: list |
| 312 |
elements: str |
| 313 |
reasons: |
| 314 |
description: |
| 315 |
- List of reasons that this distribution point can be used for when performing revocation checks. |
| 316 |
type: list |
| 317 |
elements: str |
| 318 |
choices: |
| 319 |
- key_compromise |
| 320 |
- ca_compromise |
| 321 |
- affiliation_changed |
| 322 |
- superseded |
| 323 |
- cessation_of_operation |
| 324 |
- certificate_hold |
| 325 |
- privilege_withdrawn |
| 326 |
- aa_compromise |
| 327 |
version_added: 1.4.0 |
| 328 |
notes: |
| 329 |
- If the certificate signing request already exists it will be checked whether subjectAltName, keyUsage, extendedKeyUsage |
| 330 |
and basicConstraints only contain the requested values, whether OCSP Must Staple is as requested, and if the request was |
| 331 |
signed by the given private key. |
| 332 |
seealso: |
| 333 |
- module: community.crypto.x509_certificate |
| 334 |
- module: community.crypto.x509_certificate_pipe |
| 335 |
- module: community.crypto.openssl_dhparam |
| 336 |
- module: community.crypto.openssl_pkcs12 |
| 337 |
- module: community.crypto.openssl_privatekey |
| 338 |
- module: community.crypto.openssl_privatekey_pipe |
| 339 |
- module: community.crypto.openssl_publickey |
| 340 |
- module: community.crypto.openssl_csr_info |
| 341 |
- plugin: community.crypto.parse_serial |
| 342 |
plugin_type: filter |
| 343 |
""" |