Skip to content

Commit ed10b41

Browse files
committed
Fix client cert revoke error with easyrsa 3.0
In easyrsa 3.0 (used in CentOS) the command has changed. Now there is only a single binary to run the scripts. Further the generation of CRL also has changed; now a new crl.pem file is created in keys/crl.pem which overrides the symlink there. So the revocation check did not work anymore, because the crl.pem in the base directory was not checked when a client connected. Resolves: VSHNOPS-1537
1 parent a8dc5ad commit ed10b41

File tree

2 files changed

+51
-10
lines changed

2 files changed

+51
-10
lines changed

manifests/revoke.pp

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,30 @@
2525

2626
$etc_directory = $openvpn::etc_directory
2727

28-
exec { "revoke certificate for ${name} in context of ${server}":
29-
command => ". ./vars && ./revoke-full ${name}; echo \"exit $?\" | grep -qE '(error 23|exit (0|2))' && touch revoked/${name}",
30-
cwd => "${etc_directory}/openvpn/${server}/easy-rsa",
31-
creates => "${etc_directory}/openvpn/${server}/easy-rsa/revoked/${name}",
32-
provider => 'shell',
28+
case $openvpn::easyrsa_version {
29+
'3.0': {
30+
exec { "revoke certificate for ${name} in context of ${server}":
31+
command => ". ./vars && ./easyrsa --batch revoke ${name}; echo \"exit $?\" | grep -qE '(error 23|exit (0|2|))' && touch revoked/${name}",
32+
cwd => "${etc_directory}/openvpn/${server}/easy-rsa",
33+
creates => "${etc_directory}/openvpn/${server}/easy-rsa/revoked/${name}",
34+
provider => 'shell',
35+
}
36+
# `easyrsa gen-crl` does not work, since it will create the crl.pem
37+
# to keys/crl.pem which is a symlinked to crl.pem in the servers etc
38+
# directory
39+
exec { "renew crl.pem for ${name}":
40+
command => ". ./vars && EASYRSA_REQ_CN='' EASYRSA_REQ_OU='' openssl ca -gencrl -out ../crl.pem -config ./openssl.cnf",
41+
cwd => "${openvpn::etc_directory}/openvpn/${server}/easy-rsa",
42+
provider => 'shell',
43+
}
44+
}
45+
default: {
46+
exec { "revoke certificate for ${name} in context of ${server}":
47+
command => ". ./vars && ./revoke-full ${name}; echo \"exit $?\" | grep -qE '(error 23|exit (0|2))' && touch revoked/${name}",
48+
cwd => "${etc_directory}/openvpn/${server}/easy-rsa",
49+
creates => "${etc_directory}/openvpn/${server}/easy-rsa/revoked/${name}",
50+
provider => 'shell',
51+
}
52+
}
3353
}
3454
}

spec/defines/openvpn_revoke_spec.rb

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,33 @@
2424
let(:params) { { 'server' => 'test_server' } }
2525

2626
it { is_expected.to compile.with_all_deps }
27+
context 'easyrsa version 2.0' do
28+
let(:facts) do
29+
super().merge('easyrsa' => '2.0')
30+
end
2731

28-
it {
29-
is_expected.to contain_exec('revoke certificate for test_client in context of test_server').with(
30-
'command' => ". ./vars && ./revoke-full test_client; echo \"exit $?\" | grep -qE '(error 23|exit (0|2))' && touch revoked/test_client"
31-
)
32-
}
32+
it {
33+
is_expected.to contain_exec('revoke certificate for test_client in context of test_server').with(
34+
'command' => ". ./vars && ./revoke-full test_client; echo \"exit $?\" | grep -qE '(error 23|exit (0|2))' && touch revoked/test_client"
35+
)
36+
}
37+
end
38+
context 'easyrsa version 3.0' do
39+
let(:facts) do
40+
super().merge('easyrsa' => '3.0')
41+
end
42+
43+
it {
44+
is_expected.to contain_exec('revoke certificate for test_client in context of test_server').with(
45+
'command' => ". ./vars && ./easyrsa --batch revoke test_client; echo \"exit $?\" | grep -qE '(error 23|exit (0|2|))' && touch revoked/test_client"
46+
)
47+
}
48+
it {
49+
is_expected.to contain_exec('renew crl.pem for test_client').with(
50+
'command' => ". ./vars && EASYRSA_REQ_CN='' EASYRSA_REQ_OU='' openssl ca -gencrl -out ../crl.pem -config ./openssl.cnf"
51+
)
52+
}
53+
end
3354
end
3455
end
3556
end

0 commit comments

Comments
 (0)