Commit Graph

56 Commits (8de9376a108fb34f96defd475e6b26b54575bf30)

Author SHA1 Message Date
Felix Fontein 35a78dbc4e
Improve openssl_privatekey docs. (#198) 2021-03-15 08:28:02 +01:00
Felix Fontein a1897fd3b1
luks_device: add sector_size option (#193)
* Add sector_size option to luks_device.

* Trying to improve error handling.

* Improve error handling.
2021-03-02 22:02:31 +01:00
Felix Fontein ea889ce2ad
Linting. (#191) 2021-02-11 07:53:50 +01:00
Felix Fontein 4b638a9608
Improve documentation, in particular of ACME modules (#181)
* Use B(...) instead of RST formatting (which does not work for options).

* Improve the documentation on acme_directory.

It now mentions the ACME v1 deprecation for Let's Encrypt,
and mentions that ZeroSSL works.

* Improve ACME module documentation.

* Update plugins/doc_fragments/acme.py
2021-02-02 19:29:49 +01:00
Felix Fontein 15a0be6107
Deprecate returning orders when retrieve_orders=url_list. (#178)
This allows to get rid of the ignore.txt entries for the return value syntax
error since then orders will always have the same type when returned.
2021-01-27 09:03:34 +01:00
Felix Fontein c7ef362d7a
openssl_pkcs12: allow to specify certificate bundles in other_certificates (#166)
* Rename identify.py to pem.py.

* Move split PEM list code to pem.py crypto module_utils.

* Extend and use global certificate splitting code in acme_certificate.

* openssl_pkcs12: allow to load multiple certificates from files mentioned in other_certificates.

* Add changelog and module_utils redirect.

* Remove old check.

* Fix typo.

* Apply suggestions from code review

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>

* Add example.

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
2021-01-26 10:21:49 +01:00
Felix Fontein d8ccebce60
openssl_csr: allow to specify CRL distribution endpoints (#167)
* Improve error messages for name decoding (not all names appear in SANs).

* Refactor DN parsing, add relative DN parsing code.

* Allow to specify CRL distribution points.

* Add changelog fragment.

* Fix typo.

* Make sure value argument to x509.NameAttribute is a text.

* Update changelogs/fragments/167-openssl_csr-crl-distribution-points.yml

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>

* Add example.

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
2021-01-26 09:57:40 +01:00
Felix Fontein d921ff1f68
Allow to configure PBKDF (#163)
* Allow to configure PBKDF.

* Also add PBKDF options to key add operation.

* Simplify code.

* Update plugins/modules/luks_device.py

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>

* Fix indent.

* Use more of the options.

* Bump iteration count.

* Increase memory limit.

* Fall back to default PBKDF.

* Apply suggestions from code review

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
2021-01-22 12:21:03 +00:00
Orosz Dávid 3ca4c48b00
acme_certificate: Improve challenge docs (#175)
* Fix "'list object' has no attribute 'value'" error
2021-01-22 08:01:07 +01:00
NorthFuture 2031787506
Added sever name option to use for SNI (#172)
* Added sever name option to use for SNI

* cleanup code

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

* added module version for new parameter

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

* added SNI explanation

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

* added SNI link to module description

* linting

* cleanup code

* Update plugins/modules/get_certificate.py

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

* integration test for SNI server_name option

Co-authored-by: Felix Fontein <felix@fontein.de>
2021-01-17 12:21:12 +01:00
Felix Fontein d43998facf
acme_certificate: error when requested challenge type is not found for non-valid challenges instead of hanging (#173)
* Error when requested challenge type is not found for non-valid challenges, instead of hanging on step 2.

* Only run check on first step.
2021-01-17 12:17:52 +01:00
Felix Fontein ccb25eab36
luks_device - make add/removal of keyfile/passphrase idempotent (#168)
* Update documentation, adjust tests, add changelog fragment.

* Move module unit test to correct place.

* Implement keyfile / passphrase test.
2021-01-03 11:22:41 +01:00
AutumnalAntlers fb2f3ef2b5
Correct minor typo in OpenSSH module documentation (#164)
Co-authored-by: Antlers <Antlers@luris.net>
2020-12-31 09:43:04 +01:00
Andrew Klychkov b2e13d3c03
Documentation: fix modules formatting (#161)
* Documentation: fix modules formatting

* Apply suggestions from code review

* Fix sanity

Co-authored-by: Felix Fontein <felix@fontein.de>
2020-12-19 17:15:10 +01:00
Andrew Klychkov 2c25719da5
Documentation: fix formatting (#157)
* Documentation: fix formatting

* Apply suggestions from code review

Co-authored-by: Felix Fontein <felix@fontein.de>
2020-12-12 18:19:49 +01:00
Felix Fontein 69335a8bac
Refactor x509_certificate module, add x509_certificate_pipe module (#135)
* Move documentation to doc fragment.

* Prepare module backends.

* Linting.

* Fix comments.

* First shot at actually moving code.

* Forgot SKI check.

* Remove unused imports.

* Improve check mode.

* Fix 'returned'.

* Move csr_* checks.

* Explicitly specify parameter.

* Add x509_certificate_pipe module.

* Update other seealsos.

* Forgot to remove doc fragment.

* Adjust to work with macOS 10.15.

* Update plugins/module_utils/crypto/module_backends/certificate_entrust.py

Co-authored-by: Chris Trufan <31186388+ctrufan@users.noreply.github.com>

* Add changelog fragments for entrust bugfix and module refactorings.

* Restore old behavior of Entrust backend when existing certificate cannot be parsed.

* Update plugins/modules/x509_certificate_pipe.py

Co-authored-by: Chris Trufan <31186388+ctrufan@users.noreply.github.com>

* Remove Entrust provider from x509_certificate_pipe for now.

* Add own CA tests.

* One more fix for Entrust provider, when csr_content is used.

* Update plugins/modules/x509_certificate_pipe.py

Co-authored-by: Chris Trufan <31186388+ctrufan@users.noreply.github.com>

* Fix another broken example.

* Revert "Remove Entrust provider from x509_certificate_pipe for now."

This reverts commit 6ee5d7d4f99f0fe2218276a2d3f1f38b676c29b9.

* ci_complete

* Apply suggestions from code review

Co-authored-by: MarkusTeufelberger <mteufelberger@mgit.at>

* Improve example.

* Improve readability of example, add another one.

* Extend descriptions of csr_* for selfsigned.

* Improve documentation.

* Move deprecation message up.

* Explain empty choices.

Co-authored-by: Chris Trufan <31186388+ctrufan@users.noreply.github.com>
Co-authored-by: MarkusTeufelberger <mteufelberger@mgit.at>
2020-11-24 17:21:52 +01:00
Norman Ziegner 86b39733e1
openssl_pkcs12: Add a check for parsed pkcs12 files (#145)
* openssl_pkcs12: Add a check for parsed pkcs12 files

Signed-off-by: Norman Ziegner <norman.ziegner@ufz.de>

* Add changelog fragment

Signed-off-by: Norman Ziegner <norman.ziegner@ufz.de>

* openssl_pkcs12: Report changed state when a pkcs12 file is dumped

Signed-off-by: Norman Ziegner <norman.ziegner@ufz.de>

* Add a basic test for dumping a pkcs12 file

Signed-off-by: Norman Ziegner <norman.ziegner@ufz.de>

* Update changelog fragment

Signed-off-by: Norman Ziegner <norman.ziegner@ufz.de>

* Add test for dumped pkcs12 file in check mode

Signed-off-by: Norman Ziegner <norman.ziegner@ufz.de>
2020-11-23 09:14:45 +01:00
Felix Fontein 68b45c2812
Fix example in docs, and make sure to wipe result variable (#140)
* Fix example in docs, and make sure to wipe result variable.

* Update plugins/modules/openssl_privatekey_pipe.py

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
2020-11-10 10:47:16 +01:00
Felix Fontein 3c21079afa
Refactor openssl_privatekey module, move add openssl_privatekey_pipe module (#119)
* Move disk-independent parts of openssl_privatekey to module_utils and doc_fragments.

* Improve documentation.

* Add openssl_privatekey_pipe module.

* Fallback in case no fingerprints are returned.

* Prevent no_log=True for content to stop module from working correctly.

* Forgot version_added.

* Update copyright. All the interesting code is no longer in this file anyway.

* Remove file arguments.

* Add framework for action modules.

* Convert openssl_privatekey_pipe to action plugin.

* Linting.

* Bump version.

* Add return_current_key option.

* Add no_log to examples.

* Remove preparation for potential later extensibility (easy to re-add when needed).

* Fix deprecation version in docs.

* Use new ArgumentSpec object for AnsibleActionModule as well.
2020-10-28 21:52:54 +01:00
Felix Fontein 9792188b0e
Refactor openssl_csr module, add openssl_csr_pipe module (#123)
* Extract doc fragment from openssl_csr.

* Refactor openssl_csr module into backend + module.

* Add openssl_csr_pipe module.

* Add seealso references.

* ...

* Use /dev/stdin instead of -, which seems to be only supported by newer openssl versions.

* Bump version.

* DRY: use select_message_digest.

* Fix deprecation version in docs.

* Docs improvements.

* Improve argument spec handling for module backends.

* Linting.

* Fix linting problems by using kwargs.
2020-10-27 12:37:40 +01:00
Felix Fontein fd7871ae7d
Allow to run x509_certificate selfsigned provider without providing a CSR (#129)
* Allow to run x509_certificate selfsigned provider without providing a CSR.

* Add missing prefixes (unrelated).
2020-10-19 18:09:40 +02:00
Doug Stanley b32adcce78
Implement use_agent option to get signing key from ssh-agent. (#117) 2020-10-19 18:07:36 +02:00
Felix Fontein 233d1afc29
CVE-2020-25646: no_log=True missing for private key content options (#125)
* Mark private key content options as no_log (CVE-2020-25646.)

* Mention no_log for openssl_privatekey's return_content option.

* Add change PR's URL.

* Plural.
2020-10-13 14:14:05 +02:00
Felix Fontein 7d0e5e814e
Return certificate fingerprints from x509_certificate_info (#121)
* Return certificate fingerprints from x509_certificate_info.

* Update plugins/modules/x509_certificate_info.py

Co-authored-by: MarkusTeufelberger <mteufelberger@mgit.at>

Co-authored-by: MarkusTeufelberger <mteufelberger@mgit.at>
2020-10-13 10:41:09 +02:00
Felix Fontein 42dd19c387
Allow to pass CSR to acme_certificate as csr_content (#115)
* Allow to pass CSR to acme_certificate as csr_content.

* Make sure contents are bytes.

* No need to write CSR to disk.

* Forgot version_added.

* Fix documentation.
2020-10-09 14:01:34 +02:00
Felix Fontein 7cdfdc1bfb
openssl_pkcs12: do not crash when there's no certificate and/or private key in existing PKCS#12 file (#109)
* Do not crash when PKCS#12 file contains no private key and/or main certificate.

* Add changelog fragment.

* Call getters only once each, check explicitly for None.

* Add test.

* Also 'parse' correctly PKCS#12 file with no private key.
2020-09-16 09:25:24 +00:00
Felix Fontein a2f36f426a
openssl_csr: catch errors on bad SANs (#106)
* Catch errors on bad SANs.

* Add changelog fragment.

* Adjust cryptography version and error message.
2020-09-08 04:24:30 +00:00
Felix Fontein 430c6d0c1a
Increase # of bits for random serial numbers of certificates with PyOpenSSL backend (#90)
* Increase # of bits for random serial numbers of certificates with PyOpenSSL backend.

* Adjust algorithm to return a random number between 1000 and 2^160-1.
2020-08-18 16:34:01 +02:00
Markus Teufelberger 346c2f55ff Update openssl_signature module (#63)
* Use module_utils from collection, clean up code a bit

 * add DSA keys, because why not...

 * sign/verify was added in pyOpenSSL 0.11 apparently

 * Add signing capability detection to module_utils.crypto.basic

 * Rework feature detection of signature types.

 * Rename parameters to match other modules

 * Add initial version of integration tests

 * fix whitespace in tests

 * More whitespace fixes

 * small fixes for issues in testing

 * Organize integration tests as test matrix

 * another indentation fix to make pep8 happy

 * use openssl pkeyutl when possible, otherwise fall back to openssl dgst

 * More linter fixes

 * openssl pkeyutl -help can apparently return 1

 * ignore errors on openssl call and another try at formatting

 * Remove the OpenSSL calls in tests

 * Add collection name to deprecation notice and deprecate at version 2.0.0

 * Exclude Ed448/25519 tests on pyopenssl

 * revert the collection name in the deprecation notice (breaks 2.9)

 * limit test platforms even more

 * disable FreeBSD DSA and ECC tests

 * Add module name to README

 * rewrite and split into 2 modules instead

 * add module to README and fix whitespace issue

 * remove duplicated tests

 * address review remarks

 * resolve another comment
2020-08-18 15:18:59 +02:00
Patrick Pichler 128991c3dc Add openssl_signature module (#63) 2020-08-18 15:18:56 +02:00
Felix Fontein 84342fce4e
openssl_csr: add support for name constraints extension (#92)
* Add support for name constraints extension to openssl_csr.

* Linting.

* Add tests.

* Fix IP address general name handling.
2020-08-18 12:23:37 +02:00
Felix Fontein d03e723fe0
acme_account: add support for External Account Binding (#100)
* acme_account: add support for External Account Binding.

* Add changelog fragment.

* Error if externalAccountRequired is set in ACME directory meta, but external account data is not provided.

* Validate that EAB key is Base64URL encoded.

* Improve documentation.

* Add padding to Base64 encoded key if necessary.

* Make account creation idempotent with ZeroSSL.
2020-08-16 18:00:26 +02:00
Felix Fontein 2f59d44f9e
acme_certificate - allow to select first certificate in chain. (#102) 2020-08-15 21:50:09 +02:00
Arnoways e4c12fa4e5
Add cipher and hash options to luks_create (#97) 2020-08-13 22:17:36 +02:00
s-hamann a72f9f53a4
Add support for PKCS#11 tokens to openssh_cert. (#95)
This adds the parameter pkcs11_provider, which can be set to the name of
or path to a PKCS#11 library (e.g. libpkcs11.so). ssh-keygen will then
use this library to have the token make any required signatures.
If this is used, signing_key needs to be set to a file containing the
public key that matches the private key on the token.
2020-08-04 17:59:24 +02:00
Felix Fontein a19756ee77
Fix acme_inspect problem with Python 3.5 (#87)
* Fix JSON loading problem with Python 3.5.

* Add changelog fragment.

* Enable 3.5 tests.
2020-07-13 21:10:23 +02:00
Baptiste Mille-Mathias 0786e93bb9
Add SNI support to module get_certificates (#84)
* get_certificate - Add support of SNI

For python versions supporting `create_default_context` support SNI by using low-level
SSLContext.wrap_socket().getpeercert().

Add also more information in the error message

fixes #69

* Make sure default CA certificates are not loaded when ca_cert is specified.

* Refactor to combine common code.

* Update changelogs/fragments/get_certificate-add_support_for_SNI.yml

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

Co-authored-by: Felix Fontein <felix@fontein.de>
2020-07-13 18:05:58 +02:00
Baptiste Mille-Mathias f404031d01
Fix FQCNs (#83) 2020-07-08 21:37:33 +02:00
Abhijeet Kasurde 5b8cd4944b
x509_certificate: Update docs for macOS 10.15 requirements (#78)
selfsigned_not_after and ownca_not_after values for macOS 10.15,
can be +825d. Updated the docs accordingly.

Migrated from ansible/ansible#64563

Thanks to Sironheart

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-07-01 15:28:50 +02:00
Felix Fontein 79f4d869ad
Fix sanity test errors. (#79) 2020-07-01 14:16:52 +02:00
Felix Fontein 390cb1ccc1
Prepare release (#75)
* Improve changelog generator config.

* We don't have docs at that URL.

* Require Ansible(-base) 2.9.10 or newer.

Needed for deprecation syntax.

* Update all deprecations from Ansible 2.1x to community.crypto 2.0.0.

* Forgot to check in fixes.

* Shorten lines.

* Fix unit test requirements.

* Fix YAML strings which only had a closing quote.

* Galaxy neither likes uppercase nor spaces in tags.

* General README improvements.

* Add roadmap section to README.

* Next release will be 1.0.0.

* Extend using instructions.

* Tags with dashes are also not allowed.

* Fix changelog link.
2020-07-01 13:49:25 +02:00
Felix Fontein 109edecd78
Add version_added: 1.0.0 for all new features. (#37) 2020-06-29 15:21:35 +02:00
Jordan Borean 70683e540d
Support otherName in subAltName in CSR for UTF8 strings (#53)
* Support otherName in subAltName in CSR for UTF8 strings

* Remove uneeded docs and added changelog fragment

* Missed a merge conflict

* Fix up sanity issues and added test expectation

* Rename function
2020-06-23 22:38:42 +02:00
Felix Fontein cb384443e4
cryptography backend: parse dirName, RID and otherName names (#9) 2020-06-21 22:47:48 +02:00
Toshio Kuratomi cc45650e82
Use fqcn for modules listed in M() and seealso. (#72) 2020-06-17 10:29:18 +02:00
Lucas Hoffmann a3b5ff9f4f
Fix docs of openssh_keypair (#55)
The documentation diverted from the actual behaviour, the comment field is
actually considered when checking the state of an existing key.

Fixes #54.
2020-05-23 13:42:41 +02:00
Andrew Klychkov 6da3125720
Fix example formatting (#51) 2020-05-16 18:53:29 +03:00
Felix Fontein de3c99eeac
Add support for CRLs in DER format. (#29) 2020-05-15 09:57:07 +02:00
Felix Fontein 9e5969a644
Remove ANSIBLE_METADATA from modules. (#49) 2020-05-14 13:22:12 +02:00
Felix Fontein 9a096dd146
Refactor module_utils/crypto.py (#27)
* Refactor module_utils/crypto.py: split up into multiple smaller modules

* Remove superfluous files.

* Fix sanity errors.

* Move CRL entry dumping code to module_utils.

* Move obj2txt usage from CRL modules to module_utils/crpyto/cryptography_crl.

* Move generic I/O functions to plugins/module_utils/io.py.

* Add helper method for retrieving serial number of certificate.

* Add compatibility code into __init__.py.

* Fix syntax error, and add ignore.txt entries for non-empty __init__.
2020-05-12 11:19:42 +02:00