Commit Graph

243 Commits (5e59c5261e7664c9f823ff2633c67d4d5de931b5)

Author SHA1 Message Date
Felix Fontein 5e59c5261e
Fix documentation. (#751) 2024-05-05 19:57:32 +02:00
Felix Fontein aa82575a78
ACME modules: simplify code, refactor argspec handling code, move csr/csr_content to own docs fragment (#750)
* Fix bug in argspec module util.

* Move csr / csr_content to new docs fragment.

* Simplify code.

* Refactor ACME argspec creation. Add with_certificate argument for new CERTIFICATE docs fragment.
2024-05-05 14:37:52 +02:00
Felix Fontein f3c9cb7a8a
Refactor and extend argument spec helper, use for ACME modules (#749)
* Refactor argument spec helper.

* Remove superfluous comments.
2024-05-05 09:42:42 +00:00
Felix Fontein f82b335916
Avoid exception if certificate has no AKI in acme_certificate. (#748)
Shouldn't happen since CA-issued certs should always have AKI,
but better be safe than sorry.
2024-05-05 09:43:29 +02:00
Felix Fontein 553ab45f46
ACME: improve acme_certificate docs, include cert_id in acme_certificate_renewal_info return value (#747)
* Use community.dns.quote_txt filter instead of regex replace to quote TXT entry value.

* Fix documentation of acme_certificate's challenge_data return value.

* Also return cert_id from acme_certificate_renewal_info module.

* The cert ID cannot be computed if the certificate has no AKI.

This happens with older Pebble versions, which are used when
testing against older ansible-core/-base/Ansible versions.

* Fix AKI extraction for older OpenSSL versions.
2024-05-04 23:38:57 +02:00
Felix Fontein 59606d48ad
Add acme_certificate_renewal_info module (#746)
* Allow to provide cert_info object to get_renewal_info().

* Add acme_certificate_renewal_info module.

* Allow to provide value for 'now'.

* Actually append msg_append.

* Fix bug in module timestamp param parsing, and add tests.
2024-05-04 15:47:42 +02:00
Felix Fontein 0a15be1017
Refactor time code, add tests, fix bug when parsing absolute timestamps that omit seconds (#745)
* Add time module utils.

* Add time helpers to ACME backend.

* Add changelog fragment.

* ACME timestamp parser: do not choke on nanoseconds.
2024-05-03 22:25:39 +02:00
Felix Fontein d906914737
Create acme_certificate_deactivate_authz module (#741)
* Create acme_certificate_deactivate_authz module.

* Add ACME version check.
2024-05-01 10:32:03 +02:00
Felix Fontein 33d278ad8f
acme_certificate: allow to request renewal of a certificate according to ARI (#739)
* Allow to request renewal of a certificate according to ARI in acme_certificate.

* Improve docs.

* Fix typo and use right object.

* Add warning.
2024-04-30 10:47:49 +02:00
Felix Fontein 6d4fc589ae
Implement basic acme_ari_info module. (#732) 2024-04-30 08:47:24 +02:00
Felix Fontein 9614b09f7a
Add function for retrieval of ARI information. (#738) 2024-04-29 23:37:55 +02:00
Felix Fontein af5f4b57f8
acme module utils: add functions for parsing Retry-After header values and computation of ARI certificate IDs (#737)
* Implement Retry-After value parse.

* Add cert ID computation function.

* Add tests and links to MDN.
2024-04-29 23:06:35 +02:00
Felix Fontein c6fbe58382
Implement certificate information retrieval code in the ACME backends. (#736) 2024-04-29 22:29:43 +02:00
Felix Fontein afe7f7522c
Split up the default acme docs fragment to allow modules ot not need account data. (#735) 2024-04-29 22:22:38 +02:00
Felix Fontein 0c62837296
crypto.math module utils: add some tests, fix quick_is_not_prime() for small primes (#733)
* Fix quick_is_not_prime() for small primes. Add some tests.

* Fix return value of convert_int_to_bytes(0, 0) on Python 2.

* Add some more test cases.

* Simplify the changelog and point out that these errors only happen for cases not happening in regular use.
2024-04-29 08:50:28 +02:00
Felix Fontein 27a9ff14fb
Add x509_certificate_convert module. (#728) 2024-04-18 05:50:36 +00:00
Felix Fontein ae548de502
Use timezone aware functionality when using cryptography >= 42.0.0 (#727)
* Use timezone aware functionality when using cryptography >= 42.0.0.

* Adjust OpenSSH certificate code to avoid functions deprecated in Python 3.12.

* Strip timezone info from isoformat() output.

* InvalidityDate.invalidity_date currently has no _utc variant.
2024-04-18 05:49:53 +00:00
Felix Fontein 1b75f1aa9c
Add and use CryptoBackend.get_ordered_csr_identifiers(). (#725) 2024-04-13 22:43:14 +02:00
Felix Fontein 08adb6b297
Deprecate check mode behavior of pipe modules. (#714) 2024-02-25 17:00:37 +01:00
Felix Fontein 1736602ce7
Allow to configure how serial numbers are provided to x509_crl. (#715) 2024-02-19 21:05:13 +01:00
Felix Fontein 6b1a3d6e68
Add conversion filters for serial numbers (#713)
* Refactoring.

* Add parse_filter and to_filter plugins.

* Mention filters when serial numbers are accepted or returned.
2024-02-18 21:27:48 +01:00
Steffen Gufler 51591891d3
luks_device: fix remove_keyslot not working when set to 0 and duplicate keys (#710)
* luks_device: fix remove_keyslot not working when set to 0

* luks_device: fix module outputting 'ok' when trying to add a key that is already present in another keyslot

* luks_device: fix breaking unit tests

* luks_device: Duplicate key test case code cleanup

* luks_device: Fix testing of LUKS passphrases when only testing one key slot

* luks_device: Fix testing of LUKS passphrases when only testing one key slot

* luks_device: Add changelog fragment for PR #710

* luks_device: Update changlog fragment
2024-02-11 12:23:21 +01:00
Felix Fontein 9ec8680936
Emit warning when consistency cannot be checked. (#705) 2024-01-27 10:39:13 +01:00
Felix Fontein 87af1f2761
Disable consistency checking of RSA keys for cryptography 42.0.0 which no longer gives access to the required function. (#702) 2024-01-26 17:47:46 +01:00
Felix Fontein b57aa4a2ca
Fix openssl_dhparam. (#698) 2024-01-25 23:42:03 +01:00
0x00ace a4edf22a9c
add allow discard option for luks devices (#693)
* add allow discard option for luks devices

* Add allow_discards to perfomance tests

* Fix version for luks devices doc

* Update plugins/modules/luks_device.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* add changelog fragment

* Update changelogs/fragments/693-allow-discards.yaml

Co-authored-by: Felix Fontein <felix@fontein.de>

* added allow_discards to the persistently stored option list

* allow_discards works with not only luks2 containers

* Update plugins/modules/luks_device.py

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
2024-01-13 09:34:07 +01:00
Felix Fontein 170d837122
Increase retry count from 5 to 10. (#685) 2023-12-08 21:36:20 +01:00
Felix Fontein b5269b25a3
Improve error reporting. (#684) 2023-12-08 20:57:49 +01:00
Felix Fontein 5d5a21fddf
Directly handle unexpected non-JSON results. (#682) 2023-12-07 22:26:04 +01:00
Felix Fontein 67f1d1129b
Fix handling of non-existing ACME accounts with Digicert ACME endpoint (#681)
* Compatibility for DigiCert CA: also accept 404 instead of 400 for non-existing accounts.

* Add changelog fragment.

* Fix URL.
2023-12-07 22:25:54 +01:00
Felix Fontein e4ba0861e5
Retry also on certain connection errors. (#680) 2023-12-04 21:34:51 +01:00
Steffen Gufler 6504e67139
luks_device: add support for keyslots (#664)
* luks_device: add support for keyslots

* luks_device: replace python3 format strings with python2 format strings, remove print statements

* luks_device: add missing copyright information in keyslot integration test files

* luks_device: updated failing unit tests for keyslot support

* luks_device: improve detection of luks version

* luks_device: Update documentation on keyslot parameters, minor code improvements

* luks_device: improve validation of keyslot parameters, fix tests for systems that do not support luks2

* luks_device: correct spelling and errors in documentation and output, check all possible locations for LUKS2 header
2023-10-29 10:53:00 +01:00
Felix Fontein 428550165a
Fix typos and FQCN (#669)
* Fix typos.

* Use FQCNs in examples.
2023-10-28 22:54:56 +02:00
Felix Fontein d1299c11d6
Handle pyOpenSSL 23.3.0, which removed PKCS#12 support (at least partially). (#666) 2023-10-28 13:38:07 +00:00
Felix Fontein d63c195bff
Emphasize that openssl_publickey doesn't support OpenSSH private keys. (#663) 2023-10-07 15:21:09 +02:00
Felix Fontein 526b3c4393
Allow type to be missing. (#652) 2023-08-21 20:49:55 +02:00
Felix Fontein addbd067c8
openssh_* modules: check return code on ssh(-keygen) invocations; fail if comment cannot be updated (#646)
* Check return code on ssh(-keygen) invocations.

* openssh_cert: only check for errors if certificate should be present and module is not in check mode.

* Handle rc check for _get_private_key().

* Add changelog fragment.

* Only pass -o for comment updating when necessary.

* Now fails if comment cannot be updated.

This was silently ignored in the past.

* Avoid failing operation.
2023-08-12 17:14:00 +02:00
Felix Fontein 62c842548d
Deprecate the default value 'false' of asn1_base64. (#600) 2023-08-12 12:23:37 +02:00
Kloppi313 5526fcac27
Update openssl_privatekey.py (#644)
added example for ECC
2023-08-08 13:40:24 +02:00
Felix Fontein ba456c5eaf
Add gpg_fingerprint lookup and filter (#639)
* Add gpg_fingerprint lookup.

* Work around problems on some CI targets.

* Use get_bin_path to find the gpg executable. Document that we need it.

* Improve and test error handling.

* Refactor (potentially) common code to module_utils and plugin_utils.

This will be useful to create a filter version of this, and further lookups, filters, and modules.

* Do not create a keyring when there isn't one.

* Fixups.

* Fix description.

* More fixes for lookup.

* Also add a gpg_fingerprint filter.

* Improve formulation.

Co-authored-by: Sandra McCann <samccann@redhat.com>

---------

Co-authored-by: Sandra McCann <samccann@redhat.com>
2023-08-02 11:16:34 +02:00
Felix Fontein 83af72a3bc
Improve PEM identification. (#628) 2023-06-27 17:35:55 +02:00
Felix Fontein 99d1521266
Use semantic markup (#626)
* Enable semantic markup.

* Use semantic markup.

* Break long lines.

* Add ignores.

* Use real option, not alias.
2023-06-24 10:00:56 +02:00
Marcin Słowikowski 9c07a8354e
Added support for certificates in DER format for `x509_certificate_info` module (#622)
* Added support for DER format

* Updated description

* Adjusted description

The content of the certificate cannot be in DER format due to an input encoding problem in the Ansible module, but it works fine when reading the certificate from a file

* Update support.py

* Added der_support_enabled flag for DER-format support

* Added changelog fragment for #603

* Fixed typo

* Fixed missing import

* Resolved issues found by static code analysis

* Update plugins/module_utils/crypto/support.py

Committed suggested change

Co-authored-by: Felix Fontein <felix@fontein.de>

* Apply suggestions from code review

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
2023-06-15 12:51:14 +02:00
Felix Fontein a7e9bb7618
Fix example. (#620) 2023-06-09 07:30:35 +02:00
Felix Fontein d823382732
Validate challenges in parallel instead of serially. (#617) 2023-06-09 06:04:34 +02:00
Felix Fontein 17702d1a76
acme_certificate: allow 'no challenge' (#615)
* Allow 'no challenge'.

* Fix undefined variable.
2023-06-05 20:54:07 +02:00
Felix Fontein 9305bfe190
Fix typo. (#616) 2023-06-04 20:12:35 +02:00
Felix Fontein 3bcc0db4fc
Improve examples: use FQCNs and always add name: to tasks (#604)
* Improve examples: use FQCNs and always add name: to tasks.

* Improve formulation.

Co-authored-by: Don Naro <dnaro@redhat.com>

* Accidentally added a period.

---------

Co-authored-by: Don Naro <dnaro@redhat.com>
2023-05-15 21:41:18 +02:00
David Zaslavsky ce3299f106
Always generate a new key pair if the private key doesn't exist (#598)
* Always generate a new key pair if the private key doesn't exist (#597)

This commit updates `KeypairBackend._should_generate()` to first check
if the original private key named by the `path` argument exists, and
return True if it does not. This brings the code in line with
the documentation, which says that a new key will always be generated if
the key file doesn't already exist.

As an alternative to the approach implemented here, I also considered
only modifying the condition in the `fail` branch of the if statement,
but I thought that would not map as cleanly to the behavior specified in
the documentation, so doing it the way I did should make it easier to
check that the code is doing the right thing just by looking at it.
I also considered doing something to make the logic more similar to
`PrivateKeyBackend.needs_regeneration()` (the openssl version of this
functionality), because the two are supposed to be acting the same way,
but I thought that'd be going beyond the scope of just fixing this bug.
If it'd be useful to make both methods work the same way, someone can
refactor the code in a future commit.

* Test different regenerate values with nonexistent keys

This commit changes the test task that generates new keys to use each of
the different values for the `regenerate` argument, which will ensure
that the module is capable of generating a key when no previous key
exists regardless of the value of `regenerate`. Previously, the task
would always run with the `partial_idempotence` value, and that obscured
a bug (#597) that would occur when it was set to `fail`. The bug was
fixed in the previous commit.
2023-05-01 21:16:42 +02:00
Felix Fontein c568923478
x509_crl: prepare releasing the mode option for AnsibleModule's use (#596)
* Prepare releasing the mode option for AnsibleModule's use.

* Update docs.
2023-04-29 20:54:24 +02:00