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

step_ca_certificate: add state parameter #188

Closed
10 tasks done
maxhoesel opened this issue Aug 13, 2022 · 0 comments
Closed
10 tasks done

step_ca_certificate: add state parameter #188

maxhoesel opened this issue Aug 13, 2022 · 0 comments
Labels
enhancement New feature or improvement to an existing one modules Something affecting one or more module
Milestone

Comments

@maxhoesel
Copy link
Collaborator

maxhoesel commented Aug 13, 2022

Right now, the step_ca_certificate module simply calls step-cli without checking for any existing certificates.
This results in the following behavior:

  • If force is false: On the second run, step-cli asks for confirmation for overwriting the existing cert, causing the module to fail.
  • If force is true: The certificate is always overwritten, even when this is not needed.

Neither of these are really ideal from a user POV.
As a user, I would like the step_ca_certificate module to ensure that a valid certificate with the desired properties exists on the system, regardless of the underlying details.
Such a valid certificate must:

  • Be present at the given path
  • Have correct parameters, such as SANs
  • Be valid (not expired)

It should be step_ca_certificates job to ensure that these conditions are met, whether that includes creating a new certificate or not.


I propose the following approach to accomplish this:

  • Introduce the serial_number parameter and other parameters from step_ca_revoke
  • Introduce the revoke_on_delete parameter
  • Introduce a state parameter with the following options:
    • present
      - If the certificate doesn't exist, is expired or has a SAN parameter mismatch, create a new certificate
      - Else, do nothing
    • revoked
      • Use either the path or the serial number and ensure that the given certificate is revoked.
    • absent
      • Delete the certificate from the system
        • If revoke_on_delete is true, revoke the certificate first
  • Change the force parameter behavior: Instead of passing force on the command line to replace existing files (which we pretty much always want given the above model), use of force with present will now generate a new certificate on every single run.

Implementing this feature would require a few steps:

  • Implement checks for certificate validity:
    • Exists
    • Parameters correct
    • Valid
  • Implement functionality for:
    • Revoke
    • Delete
    • Force behavior change
  • Implementing tests to ensure correct behavior
  • Remove the step_ca_certificate_revoke module
@maxhoesel maxhoesel added enhancement New feature or improvement to an existing one modules Something affecting one or more module labels Aug 13, 2022
@maxhoesel maxhoesel changed the title step_ca_certificate: make idempotent (don't issue certs unless needed) step_ca_certificate: make idempotent and check for validity Oct 10, 2023
@maxhoesel maxhoesel added this to the version-1 milestone Oct 10, 2023
@maxhoesel maxhoesel changed the title step_ca_certificate: make idempotent and check for validity step_ca_certificate: rework state Oct 10, 2023
@maxhoesel maxhoesel changed the title step_ca_certificate: rework state step_ca_certificate: add state parameter, enable renewal Oct 10, 2023
@maxhoesel maxhoesel changed the title step_ca_certificate: add state parameter, enable renewal step_ca_certificate: add state parameter Oct 26, 2023
maxhoesel added a commit to maxhoesel/ansible-collection-smallstep-fork that referenced this issue Oct 27, 2023
maxhoesel added a commit to maxhoesel/ansible-collection-smallstep-fork that referenced this issue Oct 27, 2023
maxhoesel added a commit to maxhoesel/ansible-collection-smallstep-fork that referenced this issue Oct 27, 2023
maxhoesel added a commit to maxhoesel/ansible-collection-smallstep-fork that referenced this issue Oct 27, 2023
maxhoesel added a commit to maxhoesel/ansible-collection-smallstep-fork that referenced this issue Oct 27, 2023
maxhoesel added a commit to maxhoesel/ansible-collection-smallstep-fork that referenced this issue Oct 27, 2023
maxhoesel added a commit to maxhoesel/ansible-collection-smallstep-fork that referenced this issue Oct 27, 2023
maxhoesel added a commit to maxhoesel/ansible-collection-smallstep-fork that referenced this issue Oct 27, 2023
maxhoesel added a commit to maxhoesel/ansible-collection-smallstep-fork that referenced this issue Oct 27, 2023
maxhoesel added a commit to maxhoesel/ansible-collection-smallstep-fork that referenced this issue Oct 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement to an existing one modules Something affecting one or more module
Projects
None yet
Development

No branches or pull requests

1 participant