Skip to content

Commit 084efb7

Browse files
authored
Merge pull request #233 from bastelfreak/test
fix: remove `nokeys` option and set default empty import/export passwords
2 parents b4f2682 + b92aaf3 commit 084efb7

File tree

4 files changed

+60
-8
lines changed

4 files changed

+60
-8
lines changed

examples/export_pkcs12_from_key.pp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,41 @@
3737
cert => '/tmp/foo2.example.com.crt',
3838
out_pass => 'mahje1Qu',
3939
}
40+
41+
# same as above, just no password for the X509/pkcs12
42+
openssl::certificate::x509 { 'foo3.example.com':
43+
ensure => present,
44+
country => 'CH',
45+
organization => 'Example.com',
46+
commonname => 'foo3.example.com',
47+
base_dir => '/tmp',
48+
owner => 'nobody',
49+
# This is just to speed up CI - use 2048 or more in production
50+
key_size => 1024,
51+
}
52+
-> openssl::export::pkcs12 { 'export3.pkcs12':
53+
ensure => 'present',
54+
basedir => '/tmp',
55+
pkey => '/tmp/foo3.example.com.key',
56+
cert => '/tmp/foo3.example.com.crt',
57+
}
58+
59+
# same as above, just with password for the X509 / no password for pkcs12
60+
openssl::certificate::x509 { 'foo4.example.com':
61+
ensure => present,
62+
country => 'CH',
63+
organization => 'Example.com',
64+
commonname => 'foo4.example.com',
65+
base_dir => '/tmp',
66+
owner => 'nobody',
67+
password => 'mahje1Qu',
68+
# This is just to speed up CI - use 2048 or more in production
69+
key_size => 1024,
70+
}
71+
-> openssl::export::pkcs12 { 'export4.pkcs12':
72+
ensure => 'present',
73+
basedir => '/tmp',
74+
pkey => '/tmp/foo4.example.com.key',
75+
cert => '/tmp/foo4.example.com.crt',
76+
in_pass => 'mahje1Qu',
77+
}

manifests/export/pem_key.pp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@
2626
) {
2727
if $ensure == 'present' {
2828
if $in_pass {
29-
$passin_opt = ['-nokeys', '-passin', 'env:CERTIFICATE_PASSIN']
29+
$passin_opt = ['-passin', 'env:CERTIFICATE_PASSIN']
3030
$passin_env = ["CERTIFICATE_PASSIN=${in_pass}"]
3131
} else {
32-
$passin_opt = []
32+
$passin_opt = ['-passin', 'pass:']
3333
$passin_env = []
3434
}
3535

3636
if $out_pass {
37-
$passout_opt = ['-nokeys', '-passout', 'env:CERTIFICATE_PASSOUT']
37+
$passout_opt = ['-passout', 'env:CERTIFICATE_PASSOUT']
3838
$passout_env = ["CERTIFICATE_PASSOUT=${out_pass}"]
3939
} else {
40-
$passout_opt = []
40+
$passout_opt = ['-nodes']
4141
$passout_env = []
4242
}
4343

manifests/export/pkcs12.pp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@
3434

3535
if $ensure == 'present' {
3636
if $in_pass {
37-
$passin_opt = ['-nokeys', '-passin', 'env:CERTIFICATE_PASSIN']
37+
$passin_opt = ['-passin', 'env:CERTIFICATE_PASSIN']
3838
$passin_env = ["CERTIFICATE_PASSIN=${in_pass}"]
3939
} else {
40-
$passin_opt = []
40+
$passin_opt = ['-passin', 'pass:']
4141
$passin_env = []
4242
}
4343

4444
if $out_pass {
45-
$passout_opt = ['-nokeys', '-passout', 'env:CERTIFICATE_PASSOUT']
45+
$passout_opt = ['-passout', 'env:CERTIFICATE_PASSOUT']
4646
$passout_env = ["CERTIFICATE_PASSOUT=${out_pass}"]
4747
} else {
48-
$passout_opt = []
48+
$passout_opt = ['-passout', 'pass:']
4949
$passout_env = []
5050
}
5151

spec/acceptance/pkcs12_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
it { expect(file('/tmp/foo2.example.com.crt')).to be_file.and(have_attributes(owner: 'nobody', group: 'root')) }
1111
it { expect(file('/tmp/foo2.example.com.key')).to be_file.and(have_attributes(owner: 'nobody', group: 'root')) }
1212
it { expect(file('/tmp/export2.pkcs12.p12')).to be_file.and(have_attributes(owner: 'root', group: 'root')) }
13+
it { expect(file('/tmp/foo3.example.com.crt')).to be_file.and(have_attributes(owner: 'nobody', group: 'root')) }
14+
it { expect(file('/tmp/foo3.example.com.key')).to be_file.and(have_attributes(owner: 'nobody', group: 'root')) }
15+
it { expect(file('/tmp/export3.pkcs12.p12')).to be_file.and(have_attributes(owner: 'root', group: 'root')) }
16+
it { expect(file('/tmp/foo4.example.com.crt')).to be_file.and(have_attributes(owner: 'nobody', group: 'root')) }
17+
it { expect(file('/tmp/foo4.example.com.key')).to be_file.and(have_attributes(owner: 'nobody', group: 'root')) }
18+
it { expect(file('/tmp/export4.pkcs12.p12')).to be_file.and(have_attributes(owner: 'root', group: 'root')) }
1319
end
1420
# rubocop:disable RSpec/RepeatedExampleGroupBody
1521
describe file('/tmp/export.pkcs12.p12') do
@@ -19,5 +25,13 @@
1925
describe file('/tmp/export2.pkcs12.p12') do
2026
its(:size) { is_expected.to be > 0 }
2127
end
28+
29+
describe file('/tmp/export3.pkcs12.p12') do
30+
its(:size) { is_expected.to be > 0 }
31+
end
32+
33+
describe file('/tmp/export4.pkcs12.p12') do
34+
its(:size) { is_expected.to be > 0 }
35+
end
2236
# rubocop:enable RSpec/RepeatedExampleGroupBody
2337
end

0 commit comments

Comments
 (0)