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

Module to generate Diffie-Hellman parameters #32620

Merged
merged 6 commits into from
Jan 26, 2018
Merged

Module to generate Diffie-Hellman parameters #32620

merged 6 commits into from
Jan 26, 2018

Conversation

thomwiggers
Copy link
Contributor

@thomwiggers thomwiggers commented Nov 7, 2017

Fixes #32577

SUMMARY

Implements diffie-hellman parameter generation to complement the openssl crypto modules. Directly calls openssl due to pyopenssl not having a dhparam api.

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

openssl_dhparam

ADDITIONAL INFORMATION
- hosts: localhost
  become: no
  tasks:
    - openssl_dhparam: size=1024 path=/tmp/dhparm
    - openssl_dhparam: path=/tmp/test state=absent

@ansibot
Copy link
Contributor

ansibot commented Nov 7, 2017

The test ansible-test sanity --test ansible-doc --python 2.7 [?] failed with the following error:

Command "ansible-doc openssl_dhparam" returned exit status 1.
>>> Standard Error
ERROR! module openssl_dhparam missing documentation (or could not parse documentation): Parsing produced an empty object.

The test ansible-test sanity --test ansible-doc --python 2.6 [?] failed with the following error:

Command "ansible-doc openssl_dhparam" returned exit status 1.
>>> Standard Error
ERROR! module openssl_dhparam missing documentation (or could not parse documentation): Parsing produced an empty object.

The test ansible-test sanity --test ansible-doc --python 3.5 [?] failed with the following error:

Command "ansible-doc openssl_dhparam" returned exit status 1.
>>> Standard Error
ERROR! module openssl_dhparam missing documentation (or could not parse documentation): Parsing produced an empty object.

The test ansible-test sanity --test ansible-doc --python 3.6 [?] failed with the following error:

Command "ansible-doc openssl_dhparam" returned exit status 1.
>>> Standard Error
ERROR! module openssl_dhparam missing documentation (or could not parse documentation): Parsing produced an empty object.

The test ansible-test sanity --test validate-modules [?] failed with the following errors:

lib/ansible/modules/crypto/openssl_dhparam.py:20:17: E302 DOCUMENTATION is not valid YAML
lib/ansible/modules/crypto/openssl_dhparam.py:56:1: E311 EXAMPLES is not valid YAML

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Nov 7, 2017

@ansibot ansibot added affects_2.5 This issue/PR affects Ansible v2.5 module This issue/PR relates to a module. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. needs_triage Needs a first human triage before being processed. new_module This PR includes a new module. new_plugin This PR includes a new plugin. support:community This issue/PR relates to code supported by the Ansible community. labels Nov 7, 2017
@thomwiggers
Copy link
Contributor Author

I'm directly calling openssl dhparam as pyOpenSSL doesn't support DH parameter generation.

An alternative would be using the cryptography library but that would introduce yet another dependency.

@ansibot
Copy link
Contributor

ansibot commented Nov 7, 2017

@MarkusTeufelberger

As a maintainer of a module in the same namespace this new module has been submitted to, your vote counts for shipits. Please review this module and add shipit if you would like to see it merged.

click here for bot help

@ansibot ansibot added community_review In order to be merged, this PR must follow the community review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Nov 7, 2017
@MarkusTeufelberger
Copy link
Contributor

Looks nice already! 👍

Please still use pyopenssl, if at all possible. You can call functions not offered by pyopenssl via the OpenSSL object like this: 793161b

In the documentation of return values you refer to private keys.

@thomwiggers
Copy link
Contributor Author

thomwiggers commented Nov 7, 2017

Using the pyopenssl-api appears to be quite complicated. I'm trying to follow https://wiki.openssl.org/index.php/Diffie_Hellman#Using_the_Low_Level_APIs but having trouble caling DH_generate_parameters_ex as I can't find DH_generator_2 or how to create the (null) BN_GENCB * pointer.

Using the pyca/cryptography module would be much more convenient (possibly also for the other modules)... but brings in new dependencies.

I've fixed the mentions of private keys.

@thomwiggers
Copy link
Contributor Author

It may actually be desirable to refactor all modules to use the cryptography library; it'd make implementing #32626 a lot easier as well.

@MarkusTeufelberger
Copy link
Contributor

I fully agree, however it was a hard requirement for my colleague and me when writing openssl_certificate and refatoring openssl_csr that it has to run on Debian Jessie. We absolutely need openssl_privatekey, openssl_csr and openssl_certificate to be fully functional on Jessie hosts. This realistically only leaves a relatively old version of pyopenssl.

Once Jessie is out of support (April 2020) I'm planning to take another look at cryptography.

@thomwiggers
Copy link
Contributor Author

Won't this just work: https://packages.debian.org/jessie/python-cryptography ? I haven't tried it, but it seems (some) version of cryptography is available.

@MarkusTeufelberger
Copy link
Contributor

Not surprisingly, since cryptography is a dependency of pyopenssl. :-)

Unfortunately, no, this won't just work. Certificate and CSR handling were implemented after 0.6 and reworked a few times later.

@jborean93 jborean93 removed the needs_triage Needs a first human triage before being processed. label Nov 8, 2017
@ansibot
Copy link
Contributor

ansibot commented Nov 16, 2017

@MarkusTeufelberger

As a maintainer of a module in the same namespace this new module has been submitted to, your vote counts for shipits. Please review this module and add shipit if you would like to see it merged.

click here for bot help

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Nov 16, 2017
@ansibot
Copy link
Contributor

ansibot commented Nov 16, 2017

@MarkusTeufelberger

As a maintainer of a module in the same namespace this new module has been submitted to, your vote counts for shipits. Please review this module and add shipit if you would like to see it merged.

click here for bot help

@MarkusTeufelberger
Copy link
Contributor

Well, since pyopenssl does not seem like an option for now and I have no need for that module anyways, I'd just like you to use extends_documentation_fragment: files as in #32664 (and make sure that at least the mode of the DH params file is set to something reasonable right from the start), then you can have my ok.

Essentially just calling out to openssl is definitely not a nice solution, but if it works for you, who am I for keeping you from submitting something that you need and that works for you upstream.

Lastly it would be really great if you also added at least some small integration tests (take a look at the existing ones) in a future PR, this stuff has a tendency of being a bit difficult on various platforms and having at least some basic assertion that something works as intended somewhere is always helpful.

@ansibot
Copy link
Contributor

ansibot commented Nov 16, 2017

@MarkusTeufelberger

As a maintainer of a module in the same namespace this new module has been submitted to, your vote counts for shipits. Please review this module and add shipit if you would like to see it merged.

click here for bot help

4 similar comments
@ansibot
Copy link
Contributor

ansibot commented Nov 16, 2017

@MarkusTeufelberger

As a maintainer of a module in the same namespace this new module has been submitted to, your vote counts for shipits. Please review this module and add shipit if you would like to see it merged.

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Nov 16, 2017

@MarkusTeufelberger

As a maintainer of a module in the same namespace this new module has been submitted to, your vote counts for shipits. Please review this module and add shipit if you would like to see it merged.

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Nov 16, 2017

@MarkusTeufelberger

As a maintainer of a module in the same namespace this new module has been submitted to, your vote counts for shipits. Please review this module and add shipit if you would like to see it merged.

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Nov 16, 2017

@MarkusTeufelberger

As a maintainer of a module in the same namespace this new module has been submitted to, your vote counts for shipits. Please review this module and add shipit if you would like to see it merged.

click here for bot help

@MarkusTeufelberger
Copy link
Contributor

shipit

@MarkusTeufelberger
Copy link
Contributor

shipit

@MarkusTeufelberger
Copy link
Contributor

Though you need one from @Spredzy too I think. ;-)

Also it probably needs to be manually merged since it contains changes to several files in different folders and ansibot doesn't merge that automatically afair.

@thomwiggers
Copy link
Contributor Author

According to the workflow documentation new modules always need a core team member to review them.

Copy link
Contributor

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM shipit

@MarkusTeufelberger
Copy link
Contributor

shipit

@felixfontein
Copy link
Contributor

bot_status

@ansibot
Copy link
Contributor

ansibot commented Jan 25, 2018

Components

lib/ansible/modules/crypto/openssl_dhparam.py
support: community
maintainers: Spredzy

test/integration/targets/openssl_dhparam/aliases
support: community
maintainers:

test/integration/targets/openssl_dhparam/tasks/main.yml
support: community
maintainers:

test/integration/targets/openssl_dhparam/tests/validate.yml
support: community
maintainers:

Metadata

waiting_on: maintainer
changes_requested_by: null
needs_info: False
needs_revision: False
needs_rebase: False
merge_commits: []
mergeable_state: clean
shippable_status: success
maintainer_shipits (module maintainers): 0
community_shipits (namespace maintainers): 1
ansible_shipits (core team members): 0
shipit_actors (maintainers or core team members): MarkusTeufelberger
shipit_actors_other: felixfontein

click here for bot help

@gundalow
Copy link
Contributor

rebuild_merge

@mscherer
Copy link
Contributor

shipit

@ansibot ansibot added shipit This PR is ready to be merged by Core and removed community_review In order to be merged, this PR must follow the community review workflow. labels Jan 25, 2018
@felixfontein
Copy link
Contributor

@gundalow: it looks like one of the CI processes is hanging (https://app.shippable.com/github/ansible/ansible/runs/52245/45/console)

@thomwiggers
Copy link
Contributor Author

bot_status

@ansibot
Copy link
Contributor

ansibot commented Jan 26, 2018

Components

lib/ansible/modules/crypto/openssl_dhparam.py
support: community
maintainers: Spredzy

test/integration/targets/openssl_dhparam/aliases
support: community
maintainers:

test/integration/targets/openssl_dhparam/tasks/main.yml
support: community
maintainers:

test/integration/targets/openssl_dhparam/tests/validate.yml
support: community
maintainers:

Metadata

waiting_on: maintainer
changes_requested_by: null
needs_info: False
needs_revision: False
needs_rebase: False
merge_commits: []
mergeable_state: clean
shippable_status: success
maintainer_shipits (module maintainers): 0
community_shipits (namespace maintainers): 1
ansible_shipits (core team members): 1
shipit_actors (maintainers or core team members): MarkusTeufelberger mscherer
shipit_actors_other: felixfontein

click here for bot help

@gundalow gundalow merged commit e2af5df into ansible:devel Jan 26, 2018
@thomwiggers thomwiggers deleted the openssl_dhparam branch January 26, 2018 08:17
Lujeni pushed a commit to Lujeni/ansible that referenced this pull request Feb 1, 2018
* Module to generate Diffie-Hellman parameters

Implements ansible#32577

* Add integration tests for openssl_dhparam

* Slightly refactor check to prevent unnecessary regeneration

* Fix code smell in tests

Highly annoying to have to do this again and again and again as the rules change during the game

* Using module.run_command() and module.atomic_move() from a tempfile.

* Remove underscore variable

Ansible prefers dummy
@dagwieers dagwieers added the crypto Crypto community (ACME, openssl, letsencrypt) label Feb 7, 2019
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.5 This issue/PR affects Ansible v2.5 crypto Crypto community (ACME, openssl, letsencrypt) module This issue/PR relates to a module. new_module This PR includes a new module. new_plugin This PR includes a new plugin. shipit This PR is ready to be merged by Core support:community This issue/PR relates to code supported by the Ansible community. test This PR relates to tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate Diffie-Hellman Parameters with openssl module
10 participants