Skip to content

Commit 4c26fad

Browse files
authored
Polish docs. (#783)
1 parent d13d186 commit 4c26fad

File tree

1 file changed

+157
-153
lines changed

1 file changed

+157
-153
lines changed

plugins/modules/get_certificate.py

Lines changed: 157 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -15,180 +15,180 @@
1515
author: "John Westcott IV (@john-westcott-iv)"
1616
short_description: Get a certificate from a host:port
1717
description:
18-
- Makes a secure connection and returns information about the presented certificate
19-
- The module uses the cryptography Python library.
20-
- Support SNI (L(Server Name Indication,https://en.wikipedia.org/wiki/Server_Name_Indication)) only with python >= 2.7.
18+
- Makes a secure connection and returns information about the presented certificate.
19+
- The module uses the cryptography Python library.
20+
- Support SNI (L(Server Name Indication,https://en.wikipedia.org/wiki/Server_Name_Indication)) only with Python 2.7 and newer.
2121
extends_documentation_fragment:
22-
- community.crypto.attributes
22+
- community.crypto.attributes
2323
attributes:
24-
check_mode:
25-
support: none
26-
details:
27-
- This action does not modify state.
28-
diff_mode:
29-
support: N/A
30-
details:
31-
- This action does not modify state.
24+
check_mode:
25+
support: none
26+
details:
27+
- This action does not modify state.
28+
diff_mode:
29+
support: N/A
30+
details:
31+
- This action does not modify state.
3232
options:
33-
host:
34-
description:
35-
- The host to get the cert for (IP is fine)
36-
type: str
37-
required: true
38-
ca_cert:
39-
description:
40-
- A PEM file containing one or more root certificates; if present, the cert will be validated against these root certs.
41-
- Note that this only validates the certificate is signed by the chain; not that the cert is valid for the host presenting it.
42-
type: path
43-
port:
44-
description:
45-
- The port to connect to
46-
type: int
47-
required: true
48-
server_name:
49-
description:
50-
- Server name used for SNI (L(Server Name Indication,https://en.wikipedia.org/wiki/Server_Name_Indication)) when hostname
51-
is an IP or is different from server name.
52-
type: str
53-
version_added: 1.4.0
54-
proxy_host:
55-
description:
56-
- Proxy host used when get a certificate.
57-
type: str
58-
proxy_port:
59-
description:
60-
- Proxy port used when get a certificate.
61-
type: int
62-
default: 8080
63-
starttls:
64-
description:
65-
- Requests a secure connection for protocols which require clients to initiate encryption.
66-
- Only available for V(mysql) currently.
67-
type: str
68-
choices:
69-
- mysql
70-
version_added: 1.9.0
71-
timeout:
72-
description:
73-
- The timeout in seconds
74-
type: int
75-
default: 10
76-
select_crypto_backend:
77-
description:
78-
- Determines which crypto backend to use.
79-
- The default choice is V(auto), which tries to use C(cryptography) if available.
80-
- If set to V(cryptography), will try to use the L(cryptography,https://cryptography.io/) library.
81-
type: str
82-
default: auto
83-
choices: [ auto, cryptography ]
84-
ciphers:
85-
description:
86-
- SSL/TLS Ciphers to use for the request.
87-
- 'When a list is provided, all ciphers are joined in order with V(:).'
88-
- See the L(OpenSSL Cipher List Format,https://www.openssl.org/docs/manmaster/man1/openssl-ciphers.html#CIPHER-LIST-FORMAT)
89-
for more details.
90-
- The available ciphers is dependent on the Python and OpenSSL/LibreSSL versions.
91-
type: list
92-
elements: str
93-
version_added: 2.11.0
94-
asn1_base64:
95-
description:
96-
- Whether to encode the ASN.1 values in the RV(extensions) return value with Base64 or not.
97-
- The documentation claimed for a long time that the values are Base64 encoded, but they
98-
never were. For compatibility this option is set to V(false).
99-
- The default value V(false) is B(deprecated) and will change to V(true) in community.crypto 3.0.0.
100-
type: bool
101-
version_added: 2.12.0
102-
tls_ctx_options:
103-
description:
104-
- TLS context options (TLS/SSL OP flags) to use for the request.
105-
- See the L(List of SSL OP Flags,https://wiki.openssl.org/index.php/List_of_SSL_OP_Flags) for more details.
106-
- The available TLS context options is dependent on the Python and OpenSSL/LibreSSL versions.
107-
type: list
108-
elements: raw
109-
version_added: 2.21.0
33+
host:
34+
description:
35+
- The host to get the cert for (IP is fine).
36+
type: str
37+
required: true
38+
ca_cert:
39+
description:
40+
- A PEM file containing one or more root certificates; if present, the cert will be validated against these root certs.
41+
- Note that this only validates the certificate is signed by the chain; not that the cert is valid for the host presenting it.
42+
type: path
43+
port:
44+
description:
45+
- The port to connect to.
46+
type: int
47+
required: true
48+
server_name:
49+
description:
50+
- Server name used for SNI (L(Server Name Indication,https://en.wikipedia.org/wiki/Server_Name_Indication)) when hostname
51+
is an IP or is different from server name.
52+
type: str
53+
version_added: 1.4.0
54+
proxy_host:
55+
description:
56+
- Proxy host used when get a certificate.
57+
type: str
58+
proxy_port:
59+
description:
60+
- Proxy port used when get a certificate.
61+
type: int
62+
default: 8080
63+
starttls:
64+
description:
65+
- Requests a secure connection for protocols which require clients to initiate encryption.
66+
- Only available for V(mysql) currently.
67+
type: str
68+
choices:
69+
- mysql
70+
version_added: 1.9.0
71+
timeout:
72+
description:
73+
- The timeout in seconds.
74+
type: int
75+
default: 10
76+
select_crypto_backend:
77+
description:
78+
- Determines which crypto backend to use.
79+
- The default choice is V(auto), which tries to use C(cryptography) if available.
80+
- If set to V(cryptography), will try to use the L(cryptography,https://cryptography.io/) library.
81+
type: str
82+
default: auto
83+
choices: [ auto, cryptography ]
84+
ciphers:
85+
description:
86+
- SSL/TLS Ciphers to use for the request.
87+
- 'When a list is provided, all ciphers are joined in order with V(:).'
88+
- See the L(OpenSSL Cipher List Format,https://www.openssl.org/docs/manmaster/man1/openssl-ciphers.html#CIPHER-LIST-FORMAT)
89+
for more details.
90+
- The available ciphers is dependent on the Python and OpenSSL/LibreSSL versions.
91+
type: list
92+
elements: str
93+
version_added: 2.11.0
94+
asn1_base64:
95+
description:
96+
- Whether to encode the ASN.1 values in the RV(extensions) return value with Base64 or not.
97+
- The documentation claimed for a long time that the values are Base64 encoded, but they
98+
never were. For compatibility this option is set to V(false).
99+
- The default value V(false) is B(deprecated) and will change to V(true) in community.crypto 3.0.0.
100+
type: bool
101+
version_added: 2.12.0
102+
tls_ctx_options:
103+
description:
104+
- TLS context options (TLS/SSL OP flags) to use for the request.
105+
- See the L(List of SSL OP Flags,https://wiki.openssl.org/index.php/List_of_SSL_OP_Flags) for more details.
106+
- The available TLS context options is dependent on the Python and OpenSSL/LibreSSL versions.
107+
type: list
108+
elements: raw
109+
version_added: 2.21.0
110110
111111
notes:
112-
- When using ca_cert on OS X it has been reported that in some conditions the validate will always succeed.
112+
- When using ca_cert on OS X it has been reported that in some conditions the validate will always succeed.
113113
114114
requirements:
115-
- "python >= 2.7 when using O(proxy_host)"
116-
- "cryptography >= 1.6"
115+
- "Python >= 2.7 when using O(proxy_host)"
116+
- "cryptography >= 1.6"
117117
118118
seealso:
119-
- plugin: community.crypto.to_serial
120-
plugin_type: filter
119+
- plugin: community.crypto.to_serial
120+
plugin_type: filter
121121
'''
122122

123123
RETURN = '''
124124
cert:
125-
description: The certificate retrieved from the port
126-
returned: success
127-
type: str
125+
description: The certificate retrieved from the port.
126+
returned: success
127+
type: str
128128
expired:
129-
description: Boolean indicating if the cert is expired
130-
returned: success
131-
type: bool
129+
description: Boolean indicating if the cert is expired.
130+
returned: success
131+
type: bool
132132
extensions:
133-
description: Extensions applied to the cert
134-
returned: success
135-
type: list
136-
elements: dict
137-
contains:
138-
critical:
139-
returned: success
140-
type: bool
141-
description: Whether the extension is critical.
142-
asn1_data:
143-
returned: success
144-
type: str
145-
description:
146-
- The ASN.1 content of the extension.
147-
- If O(asn1_base64=true) this will be Base64 encoded, otherwise the raw
148-
binary value will be returned.
149-
- Please note that the raw binary value might not survive JSON serialization
150-
to the Ansible controller, and also might cause failures when displaying it.
151-
See U(https://github.com/ansible/ansible/issues/80258) for more information.
152-
- B(Note) that depending on the C(cryptography) version used, it is
153-
not possible to extract the ASN.1 content of the extension, but only
154-
to provide the re-encoded content of the extension in case it was
155-
parsed by C(cryptography). This should usually result in exactly the
156-
same value, except if the original extension value was malformed.
157-
name:
158-
returned: success
159-
type: str
160-
description: The extension's name.
133+
description: Extensions applied to the cert.
134+
returned: success
135+
type: list
136+
elements: dict
137+
contains:
138+
critical:
139+
returned: success
140+
type: bool
141+
description: Whether the extension is critical.
142+
asn1_data:
143+
returned: success
144+
type: str
145+
description:
146+
- The ASN.1 content of the extension.
147+
- If O(asn1_base64=true) this will be Base64 encoded, otherwise the raw
148+
binary value will be returned.
149+
- Please note that the raw binary value might not survive JSON serialization
150+
to the Ansible controller, and also might cause failures when displaying it.
151+
See U(https://github.com/ansible/ansible/issues/80258) for more information.
152+
- B(Note) that depending on the C(cryptography) version used, it is
153+
not possible to extract the ASN.1 content of the extension, but only
154+
to provide the re-encoded content of the extension in case it was
155+
parsed by C(cryptography). This should usually result in exactly the
156+
same value, except if the original extension value was malformed.
157+
name:
158+
returned: success
159+
type: str
160+
description: The extension's name.
161161
issuer:
162-
description: Information about the issuer of the cert.
163-
returned: success
164-
type: dict
162+
description: Information about the issuer of the cert.
163+
returned: success
164+
type: dict
165165
not_after:
166-
description: Expiration date of the cert.
167-
returned: success
168-
type: str
166+
description: Expiration date of the cert.
167+
returned: success
168+
type: str
169169
not_before:
170-
description: Issue date of the cert.
171-
returned: success
172-
type: str
170+
description: Issue date of the cert.
171+
returned: success
172+
type: str
173173
serial_number:
174-
description:
175-
- The serial number of the cert.
176-
- This return value is an B(integer). If you need the serial numbers as a colon-separated hex string,
177-
such as C(11:22:33), you need to convert it to that form with P(community.crypto.to_serial#filter).
178-
returned: success
179-
type: int
174+
description:
175+
- The serial number of the cert.
176+
- This return value is an B(integer). If you need the serial numbers as a colon-separated hex string,
177+
such as C(11:22:33), you need to convert it to that form with P(community.crypto.to_serial#filter).
178+
returned: success
179+
type: int
180180
signature_algorithm:
181-
description: The algorithm used to sign the cert.
182-
returned: success
183-
type: str
181+
description: The algorithm used to sign the cert.
182+
returned: success
183+
type: str
184184
subject:
185-
description: Information about the subject of the cert (C(OU), C(CN), etc).
186-
returned: success
187-
type: dict
185+
description: Information about the subject of the cert (C(OU), C(CN), and so on).
186+
returned: success
187+
type: dict
188188
version:
189-
description: The version number of the certificate.
190-
returned: success
191-
type: str
189+
description: The version number of the certificate.
190+
returned: success
191+
type: str
192192
'''
193193

194194
EXAMPLES = '''
@@ -212,7 +212,11 @@
212212
ansible.builtin.debug:
213213
msg: "cert expires in: {{ expire_days }} days."
214214
vars:
215-
expire_days: "{{ (( cert.not_after | to_datetime('%Y%m%d%H%M%SZ')) - (ansible_date_time.iso8601 | to_datetime('%Y-%m-%dT%H:%M:%SZ')) ).days }}"
215+
expire_days: >-
216+
{{ (
217+
(cert.not_after | ansible.builtin.to_datetime('%Y%m%d%H%M%SZ')) -
218+
(ansible_date_time.iso8601 | ansible.builtin.to_datetime('%Y-%m-%dT%H:%M:%SZ'))
219+
).days }}
216220
217221
- name: Allow legacy insecure renegotiation to get a cert from a legacy device
218222
community.crypto.get_certificate:

0 commit comments

Comments
 (0)