Skip to content

Commit b92aaf3

Browse files
committed
Enhance PKCS12 examples
1 parent 345634a commit b92aaf3

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
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+
}

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)