14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'manifests/export/pem_key.pp', line 14
define openssl::export::pem_key (
Stdlib::Absolutepath $pfx_cert,
Stdlib::Absolutepath $pem_key = $title,
Enum['present', 'absent'] $ensure = present,
Optional[String] $in_pass = undef,
Optional[String] $out_pass = undef,
) {
if $ensure == 'present' {
$passin_opt = $in_pass ? {
undef => '',
default => "-passin pass:'${in_pass}'",
}
$passout_opt = $out_pass ? {
undef => '-nodes',
default => "-passout pass:'${out_pass}'",
}
$cmd = [
'openssl pkcs12',
"-in ${pfx_cert}",
"-out ${pem_key}",
'-nocerts',
$passin_opt,
$passout_opt,
]
exec { "Export ${pfx_cert} to ${pem_key}":
command => inline_template('<%= @cmd.join(" ") %>'),
path => $facts['path'],
creates => $pem_key,
}
} else {
file { $pem_key:
ensure => absent,
}
}
}
|