|
22 | 22 | # Specifies a server.xml file to manage. Valid options: a string containing an absolute path. |
23 | 23 | # @param show_diff |
24 | 24 | # Specifies display differences when augeas changes files, defaulting to true. Valid options: true or false. |
| 25 | +# @param cert_key_file |
| 26 | +# Specifies the path to the private key file. Valid options: a string containing an absolute path. |
| 27 | +# @param cert_file |
| 28 | +# Specifies the path to the certificate file. Valid options: a string containing an absolute path. |
| 29 | +# @param cert_chain_file |
| 30 | +# Specifies the path to the certificate chain file. Valid options: a string containing an absolute path. |
| 31 | +# @param cert_type |
| 32 | +# Specifies the type of certificate. Valid options: a string. 'RSA'. |
25 | 33 | # |
26 | 34 | define tomcat::config::server::connector ( |
27 | 35 | Optional[Stdlib::Absolutepath] $catalina_base = undef, |
|
34 | 42 | Optional[Boolean] $purge_connectors = undef, |
35 | 43 | Optional[Stdlib::Absolutepath] $server_config = undef, |
36 | 44 | Boolean $show_diff = true, |
| 45 | + Optional[Stdlib::Absolutepath] $cert_key_file = undef, |
| 46 | + Optional[Stdlib::Absolutepath] $cert_file = undef, |
| 47 | + Optional[Stdlib::Absolutepath] $cert_chain_file = undef, |
| 48 | + String[1] $cert_type = 'RSA', |
37 | 49 | ) { |
38 | 50 | include tomcat |
39 | 51 | $_catalina_base = pick($catalina_base, $tomcat::catalina_home) |
|
85 | 97 | } else { |
86 | 98 | $_additional_attributes = undef |
87 | 99 | } |
| 100 | + |
| 101 | + # Add SSLHostConfig if certificate parameters are provided |
| 102 | + if $cert_key_file and $cert_file and $cert_chain_file { |
| 103 | + $sslhostconfig_path = "Server/Service/Connector[#attribute/port='${port}']" |
| 104 | + |
| 105 | + $_sslhostconfig_changes = [ |
| 106 | + "set ${sslhostconfig_path}/Certificate/#attribute/certificateKeyFile ${cert_key_file}", |
| 107 | + "set ${sslhostconfig_path}/Certificate/#attribute/certificateFile ${cert_file}", |
| 108 | + "set ${sslhostconfig_path}/Certificate/#attribute/certificateChainFile ${cert_chain_file}", |
| 109 | + "set ${sslhostconfig_path}/Certificate/#attribute/type ${cert_type}", |
| 110 | + ] |
| 111 | + } else { |
| 112 | + $_sslhostconfig_changes = undef |
| 113 | + } |
| 114 | + |
88 | 115 | if ! empty(any2array($attributes_to_remove)) { |
89 | 116 | $_attributes_to_remove = prefix(any2array($attributes_to_remove), "rm ${base_path}/#attribute/") |
90 | 117 | } else { |
|
97 | 124 | $_protocol_change, |
98 | 125 | $_additional_attributes, |
99 | 126 | $_attributes_to_remove, |
| 127 | + $_sslhostconfig_changes, |
100 | 128 | ])) |
101 | 129 | } |
102 | 130 |
|
|
0 commit comments