-
-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TLS and x509-name verification support #118
Changes from 3 commits
b189c07
ad1456e
64d7bf0
882f701
a7c78a0
130cab5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,10 @@ | |
# and KEY_CN in vars | ||
# Default: None | ||
# | ||
# [*tls_auth*] | ||
# Boolean. Determins if a tls key is generated | ||
# Default: False | ||
# | ||
# === Examples | ||
# | ||
# openvpn::ca { | ||
|
@@ -99,6 +103,7 @@ | |
$key_cn = '', | ||
$key_name = '', | ||
$key_ou = '', | ||
$tls_auth = 'false', | ||
) { | ||
|
||
include openvpn | ||
|
@@ -175,6 +180,15 @@ | |
require => Exec["initca ${name}"], | ||
} | ||
|
||
if $tls_auth { | ||
exec { "generate tls key for ${name}": | ||
command => "openvpn --genkey --secret keys/ta.key", | ||
cwd => "/etc/openvpn/${name}/easy-rsa", | ||
creates => "/etc/openvpn/${name}/easy-rsa/keys/ta.key", | ||
provider => 'shell', | ||
require => Exec["copy easy-rsa to openvpn config folder ${name}"], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be run after |
||
} | ||
} | ||
file { "/etc/openvpn/${name}/keys": | ||
ensure => link, | ||
target => "/etc/openvpn/${name}/easy-rsa/keys", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,6 +83,17 @@ | |
# Boolean. Set if username and password required | ||
# Default: false | ||
# | ||
# [*tls_auth*] | ||
# Boolean. Activates tls-auth to Add an additional layer of HMAC | ||
# authentication on top of the TLS control channel to protect | ||
# against DoS attacks. This has to be set to the same value as on the | ||
# Server | ||
# Default: false | ||
# | ||
# [*x509_name*] | ||
# Common name of openvpn server to make an x509-name verification | ||
# Default: undef | ||
# | ||
# [*setenv*] | ||
# Hash. Set a custom environmental variable name=value to pass to script. | ||
# Default: {} | ||
|
@@ -157,6 +168,8 @@ | |
$setenv_safe = {}, | ||
$up = '', | ||
$down = '', | ||
$tls_auth = false, | ||
$x509_name = undef, | ||
) { | ||
|
||
if $pam { | ||
|
@@ -197,6 +210,15 @@ | |
target => "/etc/openvpn/${server}/easy-rsa/keys/ca.crt", | ||
require => Exec["generate certificate for ${name} in context of ${server}"], | ||
} | ||
if $tls_auth { | ||
file { "/etc/openvpn/${server}/download-configs/${name}/keys/${name}/ta.key": | ||
ensure => link, | ||
target => "/etc/openvpn/${server}/easy-rsa/keys/ta.key", | ||
require => Exec["generate certificate for ${name} in context of ${server}"], | ||
before => Exec["tar the thing ${server} with ${name}"], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please specify the dependency on the other side ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I do this I have to copy the whole code since this file is only required as long as tls_auth is true, otherwise it is not required. Or do you have any other suggestion how to solve that nicely? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right... My bad. |
||
notify => Exec["tar the thing ${server} with ${name}"], | ||
} | ||
} | ||
|
||
file { "/etc/openvpn/${server}/download-configs/${name}/${name}.conf": | ||
owner => root, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,7 +78,9 @@ | |
'auth_retry' => 'interact', | ||
'verb' => '1', | ||
'setenv' => {'CLIENT_CERT' => '0'}, | ||
'setenv_safe' => {'FORWARD_COMPATIBLE' => '1'} | ||
'setenv_safe' => {'FORWARD_COMPATIBLE' => '1'}, | ||
'tls_auth' => true, | ||
'x509_name' => 'test_server' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a trailing comma so we have less changes next time. |
||
} } | ||
let(:facts) { { | ||
:fqdn => 'somehost', | ||
|
@@ -103,6 +105,8 @@ | |
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^setenv\s+CLIENT_CERT\s+0$/)} | ||
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^setenv_safe\s+FORWARD_COMPATIBLE\s+1$/)} | ||
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^cipher\s+BF-CBC$/)} | ||
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^tls-client$/)} | ||
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^verify-x509-name\s+"test_server"\s+name$/)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add some reverse tests? So that it does not appear in the config if the parameter has not been specified? |
||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,6 +143,7 @@ | |
'persist_key' => true, | ||
'persist_tun' => true, | ||
'duplicate_cn' => true, | ||
'tls_auth' => true, | ||
} } | ||
|
||
let(:facts) { { | ||
|
@@ -189,6 +190,8 @@ | |
it { should contain_file('/etc/openvpn/test_server.conf').with_content(%r{^down "/tmp/down"$}) } | ||
it { should contain_file('/etc/openvpn/test_server.conf').with_content(%r{^script-security 2$}) } | ||
it { should contain_file('/etc/openvpn/test_server.conf').with_content(%r{^duplicate-cn$}) } | ||
it { should contain_file('/etc/openvpn/test_server.conf').with_content(%r{^tls-server$}) } | ||
it { should contain_file('/etc/openvpn/test_server.conf').with_content(%r{^tls-auth\s+/etc/openvpn/test_server/keys/ta.key\s+0$}) } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add some reverse tests? So that it does not appear in the config if the parameter has not been specified? |
||
|
||
it { should_not contain_file('/etc/openvpn/test_server.conf').with_content(/^server-poll-timeout/) } | ||
it { should_not contain_file('/etc/openvpn/test_server.conf').with_content(/^ping-timer-rem/) } | ||
|
@@ -207,7 +210,8 @@ | |
:key_expire => 365, | ||
:key_cn => 'yolo', | ||
:key_name => 'burp', | ||
:key_ou => 'NSA') | ||
:key_ou => 'NSA', | ||
:tls_auth => true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a trailing comma so we have less changes next time. |
||
} | ||
|
||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use a boolean instead of a string here.