Skip to content

Commit

Permalink
Generate the acceptance test CA with SAN
Browse files Browse the repository at this point in the history
Modern tooling prefers the subjectAltName extension and the CN on a
certificate is considered deprecated. Some tools even complain about
this. However, the -addext command is unavailable on EL7 because openssl
is too old.
  • Loading branch information
ekohl authored and evgeni committed Apr 4, 2022
1 parent a033ec4 commit bf63aeb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion spec/setup_acceptance_node.pp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,20 @@
$client_cert = "${directory}/client-cert.pem"
$client_key = "${directory}/client-key.pem"

# EL7 lacks openssl -addext
if $facts['os']['release']['major'] == '7' {
$ca_cmd = "openssl req -nodes -x509 -newkey rsa:2048 -subj '/CN=${facts['networking']['fqdn']}' -keyout '${ca_key}' -out '${ca_cert}' -days 365"
} else {
$ca_cmd = "openssl req -nodes -x509 -newkey rsa:2048 -subj '/CN=${facts['networking']['fqdn']}' -addext 'subjectAltName = DNS:${facts['networking']['fqdn']}' -keyout '${ca_key}' -out '${ca_cert}' -days 365"
}

exec { 'Create certificate directory':
command => "mkdir -p ${directory}",
path => ['/bin', '/usr/bin'],
creates => $directory,
}
-> exec { 'Generate certificate':
command => "openssl req -nodes -x509 -newkey rsa:2048 -subj '/CN=${facts['networking']['fqdn']}' -keyout '${ca_key}' -out '${ca_cert}' -days 365",
command => $ca_cmd,
path => ['/bin', '/usr/bin'],
creates => $ca_cert,
logoutput => 'on_failure',
Expand Down

0 comments on commit bf63aeb

Please sign in to comment.