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

Closed
wants to merge 2 commits into from

Conversation

James-Allenby
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.

James Allenby added 2 commits October 23, 2023 16:38
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

@James-Allenby
Copy link
Author

James-Allenby 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.

Copy link
Member

Choose a reason for hiding this comment

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

#186 only does this part. If that's merged, we can close this PR.

@ekohl
Copy link
Member

ekohl commented Jul 19, 2024

#186 was merged.

@ekohl ekohl closed this Jul 19, 2024
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.

3 participants