Skip to content

Commit

Permalink
Make x509 altnames and extkeyusage optional
Browse files Browse the repository at this point in the history
The defaults of empty arrays are generating invalid openssl configs
  • Loading branch information
treydock committed Mar 22, 2024
1 parent 0c03329 commit e01db1f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
8 changes: 4 additions & 4 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,16 +408,16 @@ certificate CommonName

##### <a name="-openssl--certificate--x509--altnames"></a>`altnames`

Data type: `Array`
Data type: `Optional[Array]`

certificate subjectAltName.
Can be an array or a single string.

Default value: `[]`
Default value: `undef`

##### <a name="-openssl--certificate--x509--extkeyusage"></a>`extkeyusage`

Data type: `Array`
Data type: `Optional[Array]`

certificate extended key usage
Value | Meaning
Expand All @@ -434,7 +434,7 @@ msCodeCom | Microsoft Commercial Code Signing (authenticode)
msCTLSign | Microsoft Trust List Signing
msEFS | Microsoft Encrypted File System

Default value: `[]`
Default value: `undef`

##### <a name="-openssl--certificate--x509--organization"></a>`organization`

Expand Down
6 changes: 3 additions & 3 deletions manifests/certificate/x509.pp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@
Optional[String] $state = undef,
Optional[String] $locality = undef,
Optional[String] $unit = undef,
Array $altnames = [],
Array $extkeyusage = [],
Optional[Array[String[1]]] $altnames = undef,
Optional[Array[String[1]]] $extkeyusage = undef,
Optional[String] $email = undef,
Integer $days = 365,
Stdlib::Absolutepath $base_dir = '/etc/ssl/certs',
Expand Down Expand Up @@ -159,7 +159,7 @@
$_csr = pick($csr, "${_csr_dir}/${name}.csr")
$_key = pick($key, "${_key_dir}/${name}.key")

if !empty($altnames+$extkeyusage) {
if $altnames or $extkeyusage {
$req_ext = true
} else {
$req_ext = false
Expand Down
2 changes: 2 additions & 0 deletions spec/defines/openssl_certificate_x509_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@
%r{organizationName\s+=\s+bar}
).with_content(
%r{commonName\s+=\s+baz}
).without_content(
%r{v3_req}
)
}

Expand Down

0 comments on commit e01db1f

Please sign in to comment.