Skip to content

Commit 2a2652b

Browse files
committed
Adding support for sslhostconfig options
1 parent 5222a2c commit 2a2652b

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ tomcat::instance { 'my_tomcat_app':
125125
port => $https_port,
126126
protocol => $http_version,
127127
purge_connectors => true,
128+
cert_key_file => '/path/to/key.pem',
129+
cert_file => '/path/to/cert.pem',
130+
cert_chain_file => '/path/to/chain.pem',
131+
cert_type => 'RSA',
128132
additional_attributes => {
129133
'SSLEnabled' => bool2str($https_enabled),
130134
'maxThreads' => $https_connector_max_threads,

manifests/config/server/connector.pp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@
2222
# Specifies a server.xml file to manage. Valid options: a string containing an absolute path.
2323
# @param show_diff
2424
# 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'.
2533
#
2634
define tomcat::config::server::connector (
2735
Optional[Stdlib::Absolutepath] $catalina_base = undef,
@@ -34,6 +42,10 @@
3442
Optional[Boolean] $purge_connectors = undef,
3543
Optional[Stdlib::Absolutepath] $server_config = undef,
3644
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',
3749
) {
3850
include tomcat
3951
$_catalina_base = pick($catalina_base, $tomcat::catalina_home)
@@ -85,6 +97,21 @@
8597
} else {
8698
$_additional_attributes = undef
8799
}
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+
88115
if ! empty(any2array($attributes_to_remove)) {
89116
$_attributes_to_remove = prefix(any2array($attributes_to_remove), "rm ${base_path}/#attribute/")
90117
} else {
@@ -97,6 +124,7 @@
97124
$_protocol_change,
98125
$_additional_attributes,
99126
$_attributes_to_remove,
127+
$_sslhostconfig_changes,
100128
]))
101129
}
102130

0 commit comments

Comments
 (0)