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

Ability to generate x509 certificates with extKeyUsage #96

Merged
merged 8 commits into from
Jan 16, 2018

Conversation

madchap
Copy link
Contributor

@madchap madchap commented Jan 15, 2018

Hi,

A small contribution to be able to generate certificates with extkeyusage (i.e. my use was for clientAuth and serverAuth).

Thank you.
Best,
fred

@madchap
Copy link
Contributor Author

madchap commented Jan 15, 2018

OK, the build is OK for ruby 2.1.9, but fails for ruby 2.4.1 apparently from previous stuff, I would have little ideas on how to fix at the moment.

@@ -115,7 +131,7 @@
$_csr = pick($csr, "${_csr_dir}/${name}.csr")
$_key = pick($key, "${_key_dir}/${name}.key")

if !empty($altnames) {
if (!empty($altnames)) or (!empty($extkeyusage)) {
Copy link
Member

Choose a reason for hiding this comment

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

or maybe !empty($altnames+$extkeyusage) would work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does work. Changed as advised, thanks.

@@ -14,7 +14,7 @@ default_md = sha256
default_keyfile = privkey.pem
distinguished_name = req_distinguished_name
prompt = no
<% if @altnames and not @altnames.empty? -%>
<% if (@altnames and not @altnames.empty?) || (@extkeyusage and not @extkeyusage.empty?) -%>
Copy link
Member

Choose a reason for hiding this comment

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

It might be easier to create a variable for that (e.g. Boolean use_req) in the Puppet code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -118,6 +118,7 @@
Boolean $force = true,
String $cnf_tpl = 'openssl/cert.cnf.erb',
Boolean $encrypted = true,
Boolean $use_req,
Copy link
Member

Choose a reason for hiding this comment

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

Actually, the idea was that $use_req would be a dynamic variable, not a parameter.

Typically, it would be $use_req = !empty($altnames+$extkeyusage) since that seems to define whether to use req_extensions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. So I guess I didn't really see the need to have that on top of having req_ext already. Since it is my first attempt, I assumed (wrongly) that the scope of req_ext was not suitable. I re-submitted taking out completely use_req and use the existing req_ext as to me the semantic of the variable is pretty much the same.

Apologies for the whole mess for this little thing. I am however making sure to remember all that stuff for later. Thanks for your guidance.

@@ -115,7 +131,7 @@
$_csr = pick($csr, "${_csr_dir}/${name}.csr")
$_key = pick($key, "${_key_dir}/${name}.key")

if !empty($altnames) {
if !empty($altnames+$extkeyusage) {
Copy link
Member

Choose a reason for hiding this comment

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

Ah right, I hadn't seen that this already existed. Although I think $req_ext = !empty($altnames+$extkeyusage) would do exactly the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes you're right. I just didn't touch that code in the end, and left it in its previous state.

Copy link
Member

Choose a reason for hiding this comment

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

OK, let's leave that for later ;-)

@raphink raphink merged commit c8f1bd2 into voxpupuli:master Jan 16, 2018
@raphink raphink added the enhancement New feature or request label Mar 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants