Skip to content

Commit 0e67921

Browse files
Merge pull request #2081 from bovy89/main
Improve SSLVerify options
2 parents 14ff1b8 + 7bcfae3 commit 0e67921

File tree

5 files changed

+39
-17
lines changed

5 files changed

+39
-17
lines changed

manifests/vhost.pp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,7 +1498,7 @@
14981498
#
14991499
# @param ssl_ca
15001500
# Specifies the SSL certificate authority to be used to verify client certificates used
1501-
# for authentication. You must also set `ssl_verify_client` to use this.
1501+
# for authentication.
15021502
#
15031503
# @param ssl_cert
15041504
# Specifies the SSL certification.
@@ -1516,8 +1516,7 @@
15161516
# preferred order.
15171517
#
15181518
# @param ssl_certs_dir
1519-
# Specifies the location of the SSL certification directory to verify client certs. Will not
1520-
# be used unless `ssl_verify_client` is also set (see below).
1519+
# Specifies the location of the SSL certification directory to verify client certs.
15211520
#
15221521
# @param ssl_chain
15231522
# Specifies the SSL chain. This default works out of the box, but it must be updated in
@@ -1749,7 +1748,7 @@
17491748
$ssl_protocol = undef,
17501749
$ssl_cipher = undef,
17511750
$ssl_honorcipherorder = undef,
1752-
$ssl_verify_client = undef,
1751+
Optional[Enum['none', 'optional', 'require', 'optional_no_ca']] $ssl_verify_client = undef,
17531752
$ssl_verify_depth = undef,
17541753
Optional[Enum['none', 'optional', 'require', 'optional_no_ca']] $ssl_proxy_verify = undef,
17551754
Optional[Integer[0]] $ssl_proxy_verify_depth = undef,

spec/acceptance/apache_ssl_spec.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ class { 'apache':
3333
it { is_expected.to contain 'SSLCertificateFile "/tmp/ssl_cert"' }
3434
it { is_expected.to contain 'SSLCertificateKeyFile "/tmp/ssl_key"' }
3535
it { is_expected.to contain 'SSLCertificateChainFile "/tmp/ssl_chain"' }
36-
it { is_expected.not_to contain 'SSLCACertificateFile "/tmp/ssl_ca"' }
37-
it { is_expected.not_to contain 'SSLCARevocationPath "/tmp/ssl_crl_path"' }
38-
it { is_expected.not_to contain 'SSLCARevocationFile "/tmp/ssl_crl"' }
36+
it { is_expected.to contain 'SSLCACertificateFile "/tmp/ssl_ca"' }
37+
it { is_expected.to contain 'SSLCARevocationPath "/tmp/ssl_crl_path"' }
38+
it { is_expected.to contain 'SSLCARevocationFile "/tmp/ssl_crl"' }
3939
if apache_hash['version'] == '2.4'
40-
it { is_expected.not_to contain 'SSLCARevocationCheck "chain"' }
40+
it { is_expected.to contain 'SSLCARevocationCheck chain' }
4141
else
4242
it { is_expected.not_to contain 'SSLCARevocationCheck' }
4343
end
@@ -64,7 +64,7 @@ class { 'apache':
6464
ssl_protocol => 'test',
6565
ssl_cipher => 'test',
6666
ssl_honorcipherorder => 'test',
67-
ssl_verify_client => 'test',
67+
ssl_verify_client => 'require',
6868
ssl_verify_depth => 'test',
6969
ssl_options => ['test', 'test1'],
7070
ssl_proxyengine => true,
@@ -88,7 +88,7 @@ class { 'apache':
8888
it { is_expected.to contain 'SSLProtocol test' }
8989
it { is_expected.to contain 'SSLCipherSuite test' }
9090
it { is_expected.to contain 'SSLHonorCipherOrder test' }
91-
it { is_expected.to contain 'SSLVerifyClient test' }
91+
it { is_expected.to contain 'SSLVerifyClient require' }
9292
it { is_expected.to contain 'SSLVerifyDepth test' }
9393
it { is_expected.to contain 'SSLOptions test test1' }
9494
if apache_hash['version'] == '2.4'
@@ -111,7 +111,7 @@ class { 'apache':
111111
ssl_cert => '/tmp/ssl_cert',
112112
ssl_key => '/tmp/ssl_key',
113113
ssl_ca => '/tmp/ssl_ca',
114-
ssl_verify_client => 'test',
114+
ssl_verify_client => 'optional',
115115
}
116116
MANIFEST
117117
it 'runs without error' do
@@ -139,7 +139,7 @@ class { 'apache':
139139
ssl_cert => '/tmp/ssl_cert',
140140
ssl_key => '/tmp/ssl_key',
141141
ssl_certs_dir => '/tmp',
142-
ssl_verify_client => 'test',
142+
ssl_verify_client => 'require',
143143
}
144144
MANIFEST
145145
it 'runs without error' do
@@ -151,7 +151,7 @@ class { 'apache':
151151
it { is_expected.to contain 'SSLCertificateFile "/tmp/ssl_cert"' }
152152
it { is_expected.to contain 'SSLCertificateKeyFile "/tmp/ssl_key"' }
153153
it { is_expected.to contain 'SSLCACertificatePath "/tmp"' }
154-
it { is_expected.to contain 'SSLVerifyClient test' }
154+
it { is_expected.to contain 'SSLVerifyClient require' }
155155
it { is_expected.not_to contain 'SSLCACertificateFile' }
156156
end
157157
end

spec/defines/vhost_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,13 @@
252252
'sslonly' => 'Off',
253253
},
254254
},
255+
{
256+
'path' => '/private_1',
257+
'provider' => 'location',
258+
'ssl_options' => ['+ExportCertData', '+StdEnvVars'],
259+
'ssl_verify_client' => 'optional',
260+
'ssl_verify_depth' => '10',
261+
},
255262
],
256263
'error_log' => false,
257264
'error_log_file' => 'httpd_error_log',
@@ -941,6 +948,16 @@
941948
content: %r{^\s+GssapiLocalName\sOn$},
942949
)
943950
}
951+
it {
952+
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
953+
content: %r{^\s+SSLVerifyClient\soptional$},
954+
)
955+
}
956+
it {
957+
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
958+
content: %r{^\s+SSLVerifyDepth\s10$},
959+
)
960+
}
944961
it { is_expected.to contain_concat__fragment('rspec.example.com-additional_includes') }
945962
it { is_expected.to contain_concat__fragment('rspec.example.com-logging') }
946963
it {

templates/vhost/_directories.erb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,12 @@
339339
<%- if directory['ssl_options'] -%>
340340
SSLOptions <%= Array(directory['ssl_options']).join(' ') %>
341341
<%- end -%>
342+
<%- if directory['ssl_verify_client'] and directory['ssl_verify_client'].match('(none|optional|require|optional_no_ca)') -%>
343+
SSLVerifyClient <%= directory['ssl_verify_client'] %>
344+
<%- if directory['ssl_verify_depth'] -%>
345+
SSLVerifyDepth <%= directory['ssl_verify_depth'] %>
346+
<%- end -%>
347+
<%- end -%>
342348
<%- if directory['suphp'] and @suphp_engine == 'on' -%>
343349
suPHP_UserGroup <%= directory['suphp']['user'] %> <%= directory['suphp']['group'] %>
344350
<%- end -%>

templates/vhost/_ssl.erb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
<%- end -%>
1919
<%- if @ssl_verify_client -%>
2020
SSLVerifyClient <%= @ssl_verify_client %>
21+
<%- if @ssl_verify_depth -%>
22+
SSLVerifyDepth <%= @ssl_verify_depth %>
23+
<%- end -%>
24+
<%- end -%>
2125
<%- if @ssl_certs_dir && @ssl_certs_dir != '' -%>
2226
SSLCACertificatePath "<%= @ssl_certs_dir %>"
2327
<%- end -%>
@@ -30,13 +34,9 @@
3034
<%- if @ssl_crl -%>
3135
SSLCARevocationFile "<%= @ssl_crl %>"
3236
<%- end -%>
33-
<%- if @ssl_verify_depth -%>
34-
SSLVerifyDepth <%= @ssl_verify_depth %>
35-
<%- end -%>
3637
<%- if @ssl_crl_check && scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%>
3738
SSLCARevocationCheck <%= @ssl_crl_check %>
3839
<%- end -%>
39-
<%- end -%>
4040
<%- if @ssl_options -%>
4141
SSLOptions <%= Array(@ssl_options).join(' ') %>
4242
<%- end -%>

0 commit comments

Comments
 (0)