Commit Graph

200 Commits (dc7a765e57c69783ea070c37a557bf9a7abd2bd0)

Author SHA1 Message Date
Alexandre Mulatinho 5b3526535c luks_device.py: allows user explicity define luks format version (#61812)
* luks_device.py: allow the user create LUKS based on specific versions

- Allow user pass an option 'type' that explicits define the version of LUKS
  container that will be created. It should be 'luks1' or 'luks2' format.
- If 'label' option is defined the 'type' option will be 'luks2' independently
  of the option 'type' informed by user. (labels NEED luks2 format)

Fixes: #58973
Signed-off-by: Alexandre Mulatinho <alex@mulatinho.net>

* added the changelog fragment

Signed-off-by: Alexandre Mulatinho <alex@mulatinho.net>

* luks_device.py: make it fail in certain conditions

- Not allow user especify luks1 type and label at the same playbook

Signed-off-by: Alexandre Mulatinho <alex@mulatinho.net>
5 years ago
Andrey Klychkov 5eb5f74083 fix typos in modules (#62135) 5 years ago
Felix Fontein c19cea9b03
openssh_keypair: make sure public key has same permissions as private key (#61658)
* Make sure public key has same permissions as private key.

* Add changelog.

* Text, not binary.
5 years ago
Chris Trufan 943888b955 Fixes to ecs_certificate cert chain for #61738 (#61858)
* Fixes to ecs_certificate cert chain for #61738

* Added changelog fragment

* Fixes to ecs_certificate for cleaner join, and better integration test

* Fix integration test formatting

* End cert chain with a \n

* Update changelogs/fragments/61738-ecs-certificate-invalid-chain.yaml

Co-Authored-By: Felix Fontein <felix@fontein.de>

* Update main.yml
5 years ago
Alexandre Mulatinho e4d72dd981 luks_device.py: Allow manipulate LUKS containers with label or UUID (#61603)
* luks_device.py: Allow manipulate LUKS containers with label or UUID

- Allow create a LUKS2 container format with label support
- Allow manipulate (open, close, modify) an LUKS container based on
  both label (LUKS2 format) or UUID instead of using devices only.

Fixes: #58973
Signed-off-by: Alexandre Mulatinho <alex@mulatinho.net>

* test_luks_device.py: organizing tests to support labels

- Add label on some tests and fix errors reported by Shippable

Signed-off-by: Alexandre Mulatinho <alex@mulatinho.net>

* luks_device.py: adjusting versions and messages

- Modifying version_added from 2.9 to 2.10
- Fixing some messages
- Created a changelog fragment
- Moving blkid from scope

Fixes #58973
Signed-off-by: Alexandre Mulatinho <alex@mulatinho.net>
5 years ago
Guillaume Leroy 21b101f8e1 add option to define keysize at luks partition creation (#61522)
* add option to define keysize at luks partition creation

* Bump version_added.

* Extend tests.
5 years ago
Chris Trufan 44c18b544f Addition of ECS_Certificate Module (#60883)
* Addition of ecs_certificate module.

* Documentation and code fixes

* Updates per code review

* Doc fixes, rename of chain_path to full_chain_path, add regex for cert_Expiry check

* Fixes to pep8 check to make regexp string 'raw'.

* Mistakes with find/replace of caseing.

* Added integration tests and some doc cleanup

* Some additional assertions and test typo cleanup

* Update lib/ansible/modules/crypto/entrust/ecs_certificate.py

Co-Authored-By: Felix Fontein <felix@fontein.de>

* Responses to code review comments

* Remove fake passwords from aliases file.
5 years ago
Felix Fontein e536d0e128
openssl_*: deprecate PyOpenSSL backends (#59907)
* Deprecate PyOpenSSL backends.

* Add changelog.

* Add porting guide entry.

* Improve tests to ignore deprecations when comparing results.

* Deprecating pyopenssl backend for get_certificate and openssl_publickey.

* Fix typo.
5 years ago
Felix Fontein 7f4f2506a0
acme_certificate: make compatible to Buypass' ACME v2 testing endpoint (#60727)
* Don't unnecessarily use location from header.

* Add changelog.
5 years ago
Felix Fontein 039123ec6b
acme_account_info: retrieve orders (#59697)
* Add retrieve_orders option.

* Run acme_certificate tests also for acme_account_info; use acme_account_info to get list of orders.

* Doing some quoting.

* Improve returned description.
5 years ago
Felix Fontein 14974f5fc2
openssl_certificate_info: add ocsp_uri return value (#60393)
* Add ocsp_uri return value.

* Add changelog.

* Add integration test.

* Fix rebase error.
5 years ago
Felix Fontein fa70690e5c
openssl_certificate/csr(_info): add support for SubjectKeyIdentifier and AuthorityKeyIdentifier (#60741)
* Add support for SubjectKeyIdentifier and AuthorityKeyIdentifier to _info modules.

* Adding SubjectKeyIdentifier and AuthorityKeyIdentifier support to openssl_certificate and openssl_csr.

* Fix type of authority_cert_issuer.

* Add basic tests.

* Add changelog.

* Added proper tests for _info modules.

* Fix docs bug.

* Make sure new features are only used when cryptography backend for openssl_csr is available.

* Work around jinja2 being too old on some CI hosts.

* Add tests for openssl_csr.

* Add openssl_certificate tests.

* Fix idempotence test.

* Move one level up.

* Add ownca_create_authority_key_identifier option.

* Add ownca_create_authority_key_identifier option.

* Add idempotency check.

* Apparently the function call expected different args for cryptography < 2.7.

* Fix copy'n'paste errors and typos.

* string -> general name.

* Add disclaimer.

* Implement always_create / create_if_not_provided / never_create for openssl_certificate.

* Update changelog and porting guide.

* Add comments for defaults.
5 years ago
Felix Fontein 72365b01e0 acme_certificate: only return challenges that need to be satisfied (#61191)
* Only return challenges that need to be satisfied.

* Adjust PR #.
5 years ago
Felix Fontein d31876416b acme_certificate: improve alternate chain handling (#60742)
* Improve alternate chain handling.

* Fix chain handling.
5 years ago
Felix Fontein 0d88ec241f
openssl_certificate: fix idempotency (#60745)
* Fix openssl_certificate idempotency.

* Add changelog.

* Add integration test.
5 years ago
Felix Fontein 16056f4978
openssl_certificate: check for existence before loading CSR / private keys / ... (#60740)
* Check file existence before loading files.

* Remove superfluous import.

* Add changelog.
5 years ago
Felix Fontein 26b9c81a8e
crypto modules: fix sanity errors (#60046)
* Remove sanity warnings.

* Linting.

* More linting.

* Forgot one place.

* no_bytes -> num_bytes
5 years ago
Felix Fontein ceff0029cb
openssl_certificate: deprecate assertonly provider (#60623)
* Add deprecation marks.

* Add conversion example.

* Split long line.

* Add changelog and porting guide entry.

* Fix unrelated porting guide entry.

* Fix format.

* Fix doc mistakes found in review.

* Fix filter name.

* Compare CSR and cert subject via subject_ordered.
5 years ago
Chris Trufan 86366530e8 Entrust Datacard - Support for "entrust" provider in openssl_certificate module (#59272)
* Addition of entrust provider to openssl_certificate module

* Fix native return values of error messages and JSON response.

* Documentation and syntax fixes per ansibot.

* Refactored structure of for loop due to ansible test failures in python 2.6

* Remove OCSP functionality for inclusion in possible seperate future pull request.

* Remove reissue support.

* Indicate the entrust parameters are specific to entrust.

* Comment fixes to make it clear module_utils request is used.

* Fixes to not_after documentation

* Response to pull request comments and cleanup of error handling for bad connections to properly use the 'six' HttpError for compatibility with both Python 2/3 underlying url libraries.

* pep8/pycodestyle fixes.

* Added code fragment and response to comments.

* Update license to simplified BSD

* Fixed botmeta typo

* Include license text in api.yml

* Remove unsupported certificate types, and always submit an explicit organization to match organization in CSR

* Fix documentation misquote, add expired to a comment, and fix path check timing.

* Update changelogs/fragments/59272-support-for-entrust-provider-in-openssl_certificate_module.yaml

Co-Authored-By: Felix Fontein <felix@fontein.de>
5 years ago
Felix Fontein 6a786d0d93
openssl_publickey: add cryptography backend (#60387)
* Add cryptography backend.

* Add changelog.

* Make sure requirements are satisfied.

* Use more compatible elliptic curve.

* Decrease required version numbers.

* PyOpenSSL >= 16.0.0 is really needed.

* Update lib/ansible/modules/crypto/openssl_publickey.py

Co-Authored-By: MarkusTeufelberger <mteufelberger@mgit.at>
5 years ago
Felix Fontein 601a4b8f47
get_certificate: add cryptography backend (#60599)
* Add cryptography backend for get_certificate.

* Add changelog.

* Use short names (if possible).

* Adjust version (to behave as pyOpenSSL).

* Work around bugs (needed for cryptography 1.2.3).

* Don't run cryptography backend tests for CentOS 6.

* Bump cryptography requirement to 1.6 or newer.

Otherwise, signature_algorithm_oid isn't there, either.

* Simplify requirement text.

* CentOS 6 has cryptography 1.9, so we still need to block.

* Add auto-detect test.

* Improve YAML.
5 years ago
Felix Fontein 38435e1bd0
openssl_certificate: various assertonly bugfixes (#60658)
* Fix get_relative_time_option for byte string input. Also fix it for None input.

* Using correct property for invalid_at check.

* Fix invalid_at comparison.

* Converting relative timestamps before comparison for valid_at and invalid_at.

* Fixing key usage display for cryptography backend.

* Fix key usage comparison. OBJ_txt2nid always returns 0 for key usage identifiers.

* Add changelog.

* Fix pyOpenSSL key usage comparison.
5 years ago
Felix Fontein cf69b73c04
openssl_certificate/csr_info: add ordered issuer/subject return value (#60708)
* Add ordered issuer/subject return value.

* Add changelog.
5 years ago
sky-joker c27b5ae1a3 add option proxy to get_certificate module (#60076)
* add option proxy to get_certificate module

* Add python 2.7 or higher to requirements

* Modify requirements and add create_default_context module import check processing

* add changelog file for get_certificate

* Modify changelog file
5 years ago
Felix Fontein 84d89190c7 openssh_keypair: Forgot version_added in #59268. (#60394) 5 years ago
Maxim Babushkin dda80c46e9 openssh_keypair - Add key ``comment`` to return output (#59268)
If the comment will be provided during the key creation, it will be
diplayed in the return values.
Same will be on the comment change.
5 years ago
Maxim Babushkin 27e414200f openssh_keypair - Add public key and key comment validation (#57993)
- Split the key validation to separate private and public.
- In case public key does not exist, recreate it.
- Validate comment of the key.
- In case comment changed, update the private and public keys.
5 years ago
Steve Holton a3d55a5ddb fix spelling: certifivate -> certificate (#60369)
##### SUMMARY
spelling fix

##### ISSUE TYPE
- Docs Pull Request

+label: docsite_pr
5 years ago
Felix Fontein 8b68feb67e
acme_certificate: allow to download alternate certificate chains (#56334)
* Improve link handling.

* Also fetch alternate certificate chains.

* Add retrieve_all_alternates option.

* Simplify code.

* Forgot when condition.

* Add tests for retrieve_all_alternates.

* Fixes.

* Moved utility function for link parsing to module_utils.

* Fix grammar.
5 years ago
Felix Fontein 49e16922b2 Remove no longer necessary check (since elements is procesed for path). (#59953) 5 years ago
Felix Fontein 5d5a7d6ebe
openssl_privatekey: forgot to add secp256r1 (#58605)
* Forgot to add secp256r1. This one is the interoperable one.

* Add changelog.
5 years ago
Matt Martz 11e2ac3abf Encoding fixes to support py2 and py3 non-ascii paths (#58414)
* Encoding fixes to support py2 and py3 non-ascii paths

* Remove unused import

* endswith instead of comparing slice on bytes

* join bytes, convert to to_native after

Co-Authored-By: Toshio Kuratomi <a.badger@gmail.com>

* Fix review comments

* Add missing comma

* Encoding fixes to support py2 and py3 non-ascii paths

* Use ascii encoding on paths added to the archive also
5 years ago
lolcube 547a29805e openssh_keypair: bugfix make regenerating keypairs via force possible… (#57801)
* openssh_keypair: bugfix make regenerating keypairs via force possible / add invalid file handling

* openssh_keypair: change permissions of read-only file instead of deleting it for regeneration; add changelog fragment

* address review feedbak, refactor

* add integration tests for bigfixes

* linter: fix indent

* fixup integration tests: use force when regenerating an invalid file

* linter: fix indent

* openssh_keypair: address review feedback

* openssh_keypair: fixup, remove backtick

* openssh_keypair: address review feedback

* Only pass 'y' into stdin of ssh-keygen when file exists.
5 years ago
Felix Fontein 75ca8eb42f
openssl_certificate: fix failing SAN comparisons (#58256)
* Fix failing SAN comparison for older cryptography versions due to not implemented __hashh__ functions.

* Fix SAN comparison: IPv6 addresses need to be normalized before comparing strings.

* Add changelog.

* Fix comment.
5 years ago
Felix Fontein 4188cd299b crypto modules: Improve requirements / error messages (#57868)
* Reformat requirements.

* Include Python lib versions in lib required error messages, if available.

* Update lib/ansible/modules/crypto/openssl_publickey.py

Co-Authored-By: MarkusTeufelberger <mteufelberger@mgit.at>

* Add changelog.
5 years ago
Felix Fontein da6f6cc456 Fix missing doc type. (#57884) 5 years ago
Felix Fontein 9d67f476e6 acme_certificate: fix docs (#57557)
* Fix indentation.

* Forgot when condition for second acme_certificate call.
5 years ago
Ian Wienand 6f06fc9945 openssh_keypair: make fingerprint result a string (#57295)
The extant documentation says that the fingerprint return value is a
single string, but it is currently being returned as a split list.
Convert the returned value to a string as documented, and add some
basic test-case coverage for the return values.
5 years ago
Felix Fontein 391a1042c2 openssl_pkcs12: fix crash due to wrong path used for loading key in check mode (#56808)
* Used wrong path for private key.

* Add changelog.
5 years ago
jimwitte cb9be4ddaf Update get_certificate.py (#56594)
* Update get_certificate.py with an example to calculate number of days until cert expires from get_certificate result.

* Update lib/ansible/modules/crypto/get_certificate.py

Co-Authored-By: Felix Fontein <felix@fontein.de>
5 years ago
Nagoor Shaik 2925f6960e Update openssl_privatekey.py (#55438)
* Update openssl_privatekey.py

<!--- Your description here -->

+label: docsite_pr

* Update lib/ansible/modules/crypto/openssl_privatekey.py

Co-Authored-By: snagoor <nagoor.s@gmail.com>

* Update lib/ansible/modules/crypto/openssl_privatekey.py

Co-Authored-By: snagoor <nagoor.s@gmail.com>
5 years ago
Felix Fontein c8a15b9dbc crypto modules: use module_utils.compat.ipaddress when possible (#55278)
* Use module_utils.compat.ipaddress where possible.

* Simplify reverse pointer computation.

* Use dummy for unused variables.

* Remove from ignore list.

* Adjust fix.

* Fix text handling for Python 2.

* Add changelog.
5 years ago
Felix Fontein cb5c57bcd5 openssl_csr: fix idempotency problems (#55142)
* Add test for generating a CSR with everything, and testing idempotency.

* Proper SAN normalization before comparison.

* Fix check in cryptography backend.

* Convert SANs to text. Update comments.

* Add changelog.
5 years ago
Felix Fontein c411883618 openssl_* module_utils/crypto.py: add full list of OIDs known to current OpenSSL (#54943)
* Add full list of OIDs known to current OpenSSL.

* Remove hardcoded OIDs.

* UID -> x500UniqueIdentifier

* Reference actual version used.

* Don't normalize to lower-case.

* Change test back.

* Fix typo.

* Apply changes suggested by RedHat legal.
5 years ago
Andrea Tartaglia 0303ea2bfa openssl_pkcs12: Add idempotency checks (#54633)
* Added idempotency logic to openssl_pkcs12

Also decoupled the 'parse' and 'generate' function from the file write
as they are now used in different places that do not need the file to be
written to disk.

* Added idempotency tests for openssl_pkcs12

Also adds a new test for pkcs12 files with multiple certificates

* Regenerate if parsed file is invalid

* pkcs12_other_certificates check was wrong

* Updated ca_certificates to other_certificates

ca_certificates is left as an alias to other_certificates;
friendlyname depends on private key, so it will be ignored while
checking for idempotency if the pkey is not set;
idempotency check only checks for correct certs in the stack

* use different keys for different certs

* Added other_certificates in module docs

* Added changelog and porting guide

* removed unrelated porting guide entry

* renamed ca_cert* occurrence with other_cert
5 years ago
Felix Fontein bb52390b04 luks_device: add basic check mode (#54477)
* Add basic check mode.

* One more early exit.

* Fix naming.

* Check that device is actually an existing device.
5 years ago
Felix Fontein 0a0a2e47e0 Add openssl_csr_info module (#54921)
* Add openssl_csr_info module.

* Make OpenSSL < 1.1 compatible.

* Simply remove signature algorithm.

* Adjust minimal version.

* Fallback code for some pyOpenSSL < 16.0 versions.
5 years ago
Felix Fontein e079758b31 Move refactoring steps from #54635 to own PR. (#54690) 5 years ago
Felix Fontein 221da3e8b1 Implement Ed25519, Ed448, X25519 and X448 support (cryptography backend). (#54947) 5 years ago
Felix Fontein 7a16703dff Add openssl_privatekey_info module (#54845)
* Add openssl_privatekey_info module.

* Addressing review feedback.

* Update docs.

* Update tests.

* Work around too broad sanity checks.

* ...

* Don't die when None is returned.

* Use OpenSSL to extract RSA and DSA key data.

* Extend tests.

* Make OpenSSL code compatible to OpenSSL < 1.1.

* Rewrite tests to use result dicts instead of result lists.

* Skip ECC for too old PyOpenSSL.

* Reformulate.

* Improve return_private_key_data docs.

* Rename path_content -> content.

* Add sample.

* Cleanup.

* Add key consistency check.

* Improve description.

* Adjust minimal version.

* Fallback code for some pyOpenSSL < 16.0 versions.

* Also support Ed25519 and Ed448 keys (or not).

* Add more consistency checks.

* Verify DSA keys manually.

* Improve DSA key validation.

* Forgot one condition.

* Make validation more robust.

* Move generic arithmetic code to module_utils/crypto.py.
5 years ago