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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'manifests/export/pkcs12.pp', line 18
define openssl::export::pkcs12 (
Stdlib::Absolutepath $basedir,
Stdlib::Absolutepath $pkey,
Stdlib::Absolutepath $cert,
Enum['present', 'absent'] $ensure = present,
Optional[String] $chaincert = undef,
Optional[String] $in_pass = undef,
Optional[String] $out_pass = undef,
) {
if $ensure == 'present' {
$pass_opt = $in_pass ? {
undef => '',
default => "-passin pass:${shellquote($in_pass)}",
}
$passout_opt = $out_pass ? {
undef => '',
default => "-passout pass:${shellquote($out_pass)}",
}
$chain_opt = $chaincert ? {
undef => '',
default => "-chain -CAfile ${chaincert}",
}
$cmd = [
'openssl pkcs12 -export',
"-in ${cert}",
"-inkey ${pkey}",
"-out ${basedir}/${name}.p12",
"-name ${name}",
'-nodes -noiter',
$chain_opt,
$pass_opt,
$passout_opt,
]
exec { "Export ${name} to ${basedir}/${name}.p12":
command => inline_template('<%= @cmd.join(" ") %>'),
path => $facts['path'],
creates => "${basedir}/${name}.p12",
}
} else {
file { "${basedir}/${name}.p12":
ensure => absent,
}
}
}
|