Skip to content

Commit 3c24753

Browse files
committed
cephadm: Ensure wildcard SAN is included in RGW self-signed certs
Fix: - Updated `RgwService` in `cephadmservice.py` to append `*.` before each hostname in `zonegroup_hostnames` when generating certificates if wildcard_enabled flag is set to true. - This ensures that both the entries including the wildcard entry (example: 's3.cephlab.com' and '*.s3.cephlab.com') are included in the SAN. - After this fix, virtual host bucket access works without SSL errors. Signed-off-by: Kushal Deb <[email protected]>
1 parent 368e944 commit 3c24753

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
@@ -1043,12 +1043,15 @@ def config(self, spec: RGWSpec) -> None: # type: ignore
10431043
})
10441044

10451045
if spec.zonegroup_hostnames:
1046+
san_list = spec.zonegroup_hostnames or []
1047+
hostnames = san_list + [f"*.{h}" for h in san_list] if spec.wildcard_enabled else san_list
1048+
10461049
zg_update_cmd = {
10471050
'prefix': 'rgw zonegroup modify',
10481051
'realm_name': spec.rgw_realm,
10491052
'zonegroup_name': spec.rgw_zonegroup,
10501053
'zone_name': spec.rgw_zone,
1051-
'hostnames': spec.zonegroup_hostnames,
1054+
'hostnames': hostnames,
10521055
}
10531056
logger.debug(f'rgw cmd: {zg_update_cmd}')
10541057
ret, out, err = self.mgr.check_mon_command(zg_update_cmd)
@@ -1075,10 +1078,13 @@ def prepare_create(self, daemon_spec: CephadmDaemonDeploySpec) -> CephadmDaemonD
10751078
port = spec.get_port()
10761079

10771080
if spec.generate_cert:
1081+
san_list = spec.zonegroup_hostnames or []
1082+
custom_san_list = san_list + [f"*.{h}" for h in san_list] if spec.wildcard_enabled else san_list
1083+
10781084
cert, key = self.mgr.cert_mgr.generate_cert(
10791085
daemon_spec.host,
10801086
self.mgr.inventory.get_addr(daemon_spec.host),
1081-
custom_san_list=spec.zonegroup_hostnames
1087+
custom_san_list=custom_san_list
10821088
)
10831089
pem = ''.join([key, cert])
10841090
ret, out, err = self.mgr.check_mon_command({

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
return [self.get_port()]

0 commit comments

Comments
 (0)