Skip to content

Commit 3f1fb2e

Browse files
authored
Merge pull request ceph#61727 from Kushal-deb/fix_issue_2330954-RGW_is_not_adding_a_SAN
cephadm: Ensure wildcard SAN is included in RGW self-signed certs Reviewed-by: Adam King <[email protected]>
2 parents fba2d51 + 3c24753 commit 3f1fb2e

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

doc/cephadm/services/rgw.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,36 @@ Then apply this yaml document:
173173
Note the value of ``rgw_frontend_ssl_certificate`` is a literal string as
174174
indicated by a ``|`` character preserving newline characters.
175175

176+
Setting up HTTPS with Wildcard SANs
177+
-----------------------------------
178+
179+
To enable HTTPS for RGW services, apply a spec file following this scheme:
180+
181+
.. code-block:: yaml
182+
183+
service_type: rgw
184+
service_id: foo
185+
placement:
186+
label: rgw
187+
count_per_host: 1
188+
spec:
189+
ssl: true
190+
generate_cert: true
191+
rgw_frontend_port: 8080
192+
wildcard_enabled: true # Enables wildcard SANs in the certificate
193+
zonegroup_hostnames:
194+
- s3.cephlab.com
195+
196+
Then apply this yaml document:
197+
198+
.. prompt:: bash #
199+
200+
ceph orch apply -i myrgw.yaml
201+
202+
The ``wildcard_enabled`` flag ensures that a wildcard SAN entry is included in the self-signed certificate,
203+
allowing access to buckets in virtual host mode. By default, this flag is disabled.
204+
example: wildcard SAN - (*.s3.cephlab.com)
205+
176206
Disabling multisite sync traffic
177207
--------------------------------
178208

src/pybind/mgr/cephadm/services/cephadmservice.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,12 +1066,15 @@ def config(self, spec: RGWSpec) -> None: # type: ignore
10661066
})
10671067

10681068
if spec.zonegroup_hostnames:
1069+
san_list = spec.zonegroup_hostnames or []
1070+
hostnames = san_list + [f"*.{h}" for h in san_list] if spec.wildcard_enabled else san_list
1071+
10691072
zg_update_cmd = {
10701073
'prefix': 'rgw zonegroup modify',
10711074
'realm_name': spec.rgw_realm,
10721075
'zonegroup_name': spec.rgw_zonegroup,
10731076
'zone_name': spec.rgw_zone,
1074-
'hostnames': spec.zonegroup_hostnames,
1077+
'hostnames': hostnames,
10751078
}
10761079
logger.debug(f'rgw cmd: {zg_update_cmd}')
10771080
ret, out, err = self.mgr.check_mon_command(zg_update_cmd)
@@ -1102,10 +1105,13 @@ def prepare_create(self, daemon_spec: CephadmDaemonDeploySpec) -> CephadmDaemonD
11021105
port = ports[0]
11031106

11041107
if spec.generate_cert:
1108+
san_list = spec.zonegroup_hostnames or []
1109+
custom_san_list = san_list + [f"*.{h}" for h in san_list] if spec.wildcard_enabled else san_list
1110+
11051111
cert, key = self.mgr.cert_mgr.generate_cert(
11061112
daemon_spec.host,
11071113
self.mgr.inventory.get_addr(daemon_spec.host),
1108-
custom_san_list=spec.zonegroup_hostnames
1114+
custom_san_list=custom_san_list
11091115
)
11101116
pem = ''.join([key, cert])
11111117
self.mgr.cert_mgr.save_cert('rgw_frontend_ssl_cert', pem, service_name=spec.service_name())

src/python-common/ceph/deployment/service_spec.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,6 +1234,7 @@ def __init__(self,
12341234
rgw_bucket_counters_cache_size: Optional[int] = None,
12351235
generate_cert: bool = False,
12361236
disable_multisite_sync_traffic: Optional[bool] = None,
1237+
wildcard_enabled: Optional[bool] = False,
12371238
):
12381239
assert service_type == 'rgw', service_type
12391240

@@ -1288,6 +1289,7 @@ def __init__(self,
12881289
self.generate_cert = generate_cert
12891290
#: Used to make RGW not do multisite replication so it can dedicate to IO
12901291
self.disable_multisite_sync_traffic = disable_multisite_sync_traffic
1292+
self.wildcard_enabled = wildcard_enabled
12911293

12921294
def get_port_start(self) -> List[int]:
12931295
ports = self.get_port()

0 commit comments

Comments
 (0)