Skip to content

Commit 5855384

Browse files
committed
(CAT-1281) - Support to add cipher with respective ssl protocol
1 parent 7dc4d01 commit 5855384

File tree

6 files changed

+43
-2
lines changed

6 files changed

+43
-2
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@
236236
[`ssl`]: https://forge.puppet.com/modules/puppetlabs/apache/reference#ssl
237237
[`ssl_cert`]: https://forge.puppet.com/modules/puppetlabs/apache/reference#ssl_cert
238238
[`ssl_compression`]: https://forge.puppet.com/modules/puppetlabs/apache/reference#ssl_compression
239+
[`ssl_cipher`]: https://forge.puppet.com/modules/puppetlabs/apache/reference#ssl_compression
239240
[`ssl_key`]: https://forge.puppet.com/modules/puppetlabs/apache/reference#ssl_key
240241
[`StartServers`]: https://httpd.apache.org/docs/current/mod/mpm_common.html#startservers
241242
[supported operating system]: https://forge.puppet.com/supported#puppet-supported-modules-compatibility-matrix
@@ -657,6 +658,22 @@ class { 'apache::mod::ssl':
657658
}
658659
```
659660

661+
You can pass the SSL Ciphers to override the default ciphers.
662+
```puppet
663+
class { 'apache::mod::ssl':
664+
ssl_cipher => 'PROFILE=SYSTEM',
665+
}
666+
```
667+
668+
You can also pass the different [`ssl_cipher`][] for different SSL protocols. This allows you to fine-tune the ciphers based on the specific SSL/TLS protocol version being used.
669+
```puppet
670+
class { 'apache::mod::ssl':
671+
ssl_cipher => {
672+
'TLSv1.1' => 'RSA:!EXP:!NULL:+HIGH:+MEDIUM'
673+
},
674+
}
675+
```
676+
660677
Note that some modules have prerequisites, which are documented in their references under [`apache::mod::<MODULE NAME>`][].
661678

662679
#### Installing arbitrary modules

manifests/mod/ssl.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
Optional[Stdlib::Absolutepath] $ssl_cert = undef,
9696
Optional[Stdlib::Absolutepath] $ssl_key = undef,
9797
Optional[Stdlib::Absolutepath] $ssl_ca = undef,
98-
String $ssl_cipher = $apache::params::ssl_cipher,
98+
Variant[String, Hash[String[1], String[1]]] $ssl_cipher = $apache::params::ssl_cipher,
9999
Variant[Boolean, Apache::OnOff] $ssl_honorcipherorder = true,
100100
Array[String] $ssl_protocol = $apache::params::ssl_protocol,
101101
Array $ssl_proxy_protocol = [],

manifests/vhost.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1719,7 +1719,7 @@
17191719
Optional[Stdlib::Absolutepath] $ssl_certs_dir = $apache::params::ssl_certs_dir,
17201720
Boolean $ssl_reload_on_change = $apache::default_ssl_reload_on_change,
17211721
Optional[Variant[Array[String], String]] $ssl_protocol = undef,
1722-
Optional[Variant[Array[String], String]] $ssl_cipher = undef,
1722+
Optional[Variant[Array[String], String, Hash[String[1], String[1]]]]] $ssl_cipher = undef,
17231723
Variant[Boolean, Apache::OnOff, Undef] $ssl_honorcipherorder = undef,
17241724
Optional[Enum['none', 'optional', 'require', 'optional_no_ca']] $ssl_verify_client = undef,
17251725
Optional[Integer] $ssl_verify_depth = undef,

spec/classes/mod/ssl_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,20 @@
4545

4646
it { is_expected.to contain_file('ssl.conf').without_content(%r{SSLProtocol}) }
4747
end
48+
49+
context 'ciphers with ssl_protocol' do
50+
let(:params) do
51+
{
52+
ssl_cipher: {
53+
'TLSv1.1' => 'RSA:!EXP:!NULL:+HIGH:+MEDIUM',
54+
'TLSv1.2' => 'RSA:!EXP:!NULL:+HIGH:+MEDIUM:-LOW'
55+
}
56+
}
57+
end
58+
59+
it { is_expected.to contain_file('ssl.conf').without_content(%r{ SSLCipherSuite TLSv1.1 RSA:!EXP:!NULL:+HIGH:+MEDIUM}) }
60+
it { is_expected.to contain_file('ssl.conf').without_content(%r{ SSLCipherSuite TLSv1.2 RSA:!EXP:!NULL:+HIGH:+MEDIUM:-LOW}) }
61+
end
4862
end
4963

5064
context '7 OS with custom directories for PR#1635' do

templates/mod/ssl.conf.erb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@
3333
SSLStaplingReturnResponderErrors <%= scope.call_function('apache::bool2httpd', [@ssl_stapling_return_errors]) %>
3434
<%- end -%>
3535
SSLStaplingCache "shmcb:<%= @_stapling_cache %>"
36+
<%- if @ssl_cipher.kind_of?(Hash) -%>
37+
<%- @ssl_cipher.map do |protocol, cipher| -%>
38+
SSLCipherSuite <%= protocol %> <%= cipher %>
39+
<%- end -%>
40+
<%- else -%>
3641
SSLCipherSuite <%= @ssl_cipher %>
42+
<%- end -%>
3743
<% if not @ssl_protocol.empty? -%>
3844
SSLProtocol <%= @ssl_protocol.compact.join(' ') %>
3945
<% end -%>

templates/vhost/_ssl.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
<%- if @ssl_cipher -%>
1616
<%- if @ssl_cipher.kind_of?(String) -%>
1717
SSLCipherSuite <%= @ssl_cipher %>
18+
<%- elsif @ssl_cipher.kind_of?(Hash) -%>
19+
<%- @ssl_cipher.map do |protocol, cipher| -%>
20+
SSLCipherSuite <%= protocol %> <%= cipher%>
21+
<%- end -%>
1822
<%- else -%>
1923
SSLCipherSuite <%= @ssl_cipher.flatten.compact.join(':') %>
2024
<%- end -%>

0 commit comments

Comments
 (0)