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

use private key when creating x509 cert #170

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

MyCatFishSteve
Copy link

Pull Request (PR) description

Fixes usage of openssl::certificate::x509 where the private key was not passed into OpenSSL correctly. This could collide with L83 in lib/puppet/provider/x509_cert/openssl.rb but I don't have time to test this use case.

If there is a CAKey then use that, otherwise use a private key.
@zilchms
Copy link
Contributor

zilchms commented Jan 23, 2024

Sorry to get back to this so late.

Why would you want to pass the key parameter when you are already passing the csr parameter? My understanding is that we have 2 cases here:

  1. legacy code; we directly pass a private key and generate a csr on the fly (i kept this in, since removing it would break alot of old installations)
  2. new code; we pass a csr (which should contain a valid path to a private key), then we dont need to pass in a key to generate a certificate

Am i wrong there? Do you see this differently?
Additionally: If we want to pass the private key separately as parameter in addition to the csr, we should always do so and not only when we dont sign against a CA certificate

@MyCatFishSteve
Copy link
Author

MyCatFishSteve commented Mar 6, 2024

It's been some time since I worked on this at my job but I believe this code change was for the first use case you mentioned. Without the change, puppet happily attempt to create a certificate with OpenSSL but will error because no key was specified.

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

Please rebase to resolve the merge conflict.

@@ -80,6 +80,8 @@ def create
options << ['-CAcreateserial']
options << ['-CA', resource[:ca]]
options << ['-CAkey', resource[:cakey]]
else
options << ['-key', resource[:private_key]]
Copy link
Member

Choose a reason for hiding this comment

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

In 268ae1c the -signkey option was added, which is an alias for -key. So I think this is now redundant

ensure => $ensure,
template => $_cnf,
csr => $_csr,
private_key => $_key,
Copy link
Member

Choose a reason for hiding this comment

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

This isn't part of the current code. It happens to work now because private_key defaults to the same value as $_key defaults to. If a user passes in $key it will fail, so this is still needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants