Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Custom Cipher Selection #571

Merged
merged 7 commits into from
Feb 10, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions plugins/modules/get_certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@
type: str
default: auto
choices: [ auto, cryptography ]
ciphers:
description:
- SSL/TLS Ciphers to use for the request.
- 'When a list is provided, all ciphers are joined in order with C(:)'
dlehrman marked this conversation as resolved.
Show resolved Hide resolved
- See the L(OpenSSL Cipher List Format,https://www.openssl.org/docs/manmaster/man1/openssl-ciphers.html#CIPHER-LIST-FORMAT)
for more details.
- The available ciphers is dependent on the Python and OpenSSL/LibreSSL versions
dlehrman marked this conversation as resolved.
Show resolved Hide resolved
type: list
elements: str
dlehrman marked this conversation as resolved.
Show resolved Hide resolved

notes:
- When using ca_cert on OS X it has been reported that in some conditions the validate will always succeed.
Expand Down Expand Up @@ -247,6 +256,7 @@ def main():
timeout=dict(type='int', default=10),
select_crypto_backend=dict(type='str', choices=['auto', 'cryptography'], default='auto'),
starttls=dict(type='str', choices=['mysql']),
ciphers=dict(type='list', elements='str'),
),
)

Expand All @@ -258,6 +268,7 @@ def main():
timeout = module.params.get('timeout')
server_name = module.params.get('server_name')
start_tls_server_type = module.params.get('starttls')
ciphers = module.params.get('ciphers')

backend = module.params.get('select_crypto_backend')
if backend == 'auto':
Expand Down Expand Up @@ -325,6 +336,10 @@ def main():
if start_tls_server_type is not None:
felixfontein marked this conversation as resolved.
Show resolved Hide resolved
send_starttls_packet(sock, start_tls_server_type)

if ciphers is not None:
ciphers_joined = ":".join(ciphers)
ctx.set_ciphers(ciphers_joined)

cert = ctx.wrap_socket(sock, server_hostname=server_name or host).getpeercert(True)
cert = DER_cert_to_PEM_cert(cert)
except Exception as e:
Expand Down