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

Fix handling of request extensions in x509_cert type and provider #180

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,7 @@ discover the appropriate provider for your platform.

##### <a name="-x509_cert--req_ext"></a>`req_ext`

Valid values: `true`, `false`
Valid values: `true`, `false`, `yes`, `no`

Whether adding v3 SAN from config

Expand Down
12 changes: 10 additions & 2 deletions lib/puppet/provider/x509_cert/openssl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,21 @@ def create
'-req',
'-days', resource[:days],
'-in', resource[:csr],
'-out', resource[:path],
'-extfile', resource[:template]
'-out', resource[:path]
]
if resource[:ca]
options << ['-extfile', resource[:template]]
options << ['-CAcreateserial']
options << ['-CA', resource[:ca]]
options << ['-CAkey', resource[:cakey]]
else
options << ['-signkey', resource[:private_key]]
if resource[:req_ext]
options << [
'-extensions', 'v3_req',
'-extfile', resource[:template]
]
end
end
else
options = [
Expand Down
3 changes: 1 addition & 2 deletions lib/puppet/type/x509_cert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@
desc 'The optional password for the private key'
end

newparam(:req_ext, boolean: true) do
newparam(:req_ext, boolean: true, parent: Puppet::Parameter::Boolean) do
desc 'Whether adding v3 SAN from config'
newvalues(:true, :false)
defaultto false
end

Expand Down
2 changes: 1 addition & 1 deletion spec/unit/puppet/provider/x509_cert/openssl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
'-days', 3650,
'-in', '/tmp/foo.csr',
'-out', '/tmp/foo.crt',
'-extfile', '/tmp/foo.cnf',
['-extfile', '/tmp/foo.cnf'],
['-CAcreateserial'],
['-CA', '/tmp/foo-ca.crt'],
['-CAkey', '/tmp/foo-ca.key'],
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/puppet/type/x509_cert_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

it 'accepts a valid req_ext parameter' do
resource[:req_ext] = true
expect(resource[:req_ext]).to eq(:true)
expect(resource[:req_ext]).to be(true)
end

it 'does not accept a bad req_ext parameter' do
Expand Down