Repository navigation
rgw/sts: use the jwks_uri host and port for thumbprint verification - #73310
Conversation
With rgw_enable_jwks_url_verification enabled, verify_oidc_thumbprint()
connects to the JWKS endpoint to compare its certificate against the
thumbprints registered with the OIDC provider. The hostname was taken
from jwks_uri by stripping the scheme and path only, so an explicit port
stayed attached ("host:6443") and gethostbyname() failed on it. Even
when no port was given, the connection always went to 443. Providers
served on any other port, such as a Kubernetes API server on 6443,
could therefore never pass verification.
Add rgw::parse_url_host_port() next to the existing Boost.URL based
helpers in rgw_url.cc and use it to take both the host and the port
(default 443) from jwks_uri. Resolve the host with getaddrinfo() so that
IPv6 literals and AAAA records work as well, and try each address until
one connects.
Fixes: https://tracker.ceph.com/issues/74001
Signed-off-by: Woojoong Kim <[email protected]>
|
Thank you for your contribution. Since you are not yet a member of the Ceph organization with write permissions on ceph/ceph.git, our CI will not automatically run. Any member of the Ceph organization may label this PR |
|
@pritha-srivastava Could you approve CI? This fixes the jwks_uri port handling reported in tracker 74001. |
|
lgtm |
|
jenkins test api |
|
This PR has been added to wip-anrao8-testing-2026-11-02-0653-main. |
pr testing completed and approved by @ivancich more details on :https://tracker.ceph.com/issues/82523 |
|
|
This is an automated message by src/script/redmine-upkeep.py. I have resolved the following tracker ticket due to the merge of this PR: No backports are pending for the ticket. If this is incorrect, please update the tracker |
Problem
With
rgw_enable_jwks_url_verification = true,verify_oidc_thumbprint()opens its own TLS connection to the JWKS endpoint and compares the last certificate of the chain with the thumbprints registered on the OIDC provider. There are two defects in how it reaches the endpoint.jwks_uriby stripping only the scheme and the path. An explicit port stays attached, sohttps://host:6443/openid/v1/jwksbecomeshost:6443andgethostbyname("host:6443")fails. Evenhttps://host:443/...fails this way, as reported in the tracker.Concrete case — Kubernetes service account tokens
A Kubernetes cluster can be registered as the provider for
AssumeRoleWithWebIdentity, allowing pods to authenticate to RGW with projected service account tokens. The kube-apiserver issues those tokens and can serve discovery and JWKS directly on its HTTPS port, which defaults to 6443. For example, the discovery document could contain the following fields.{ "issuer": "https://kubernetes.default.svc.cluster.local", "jwks_uri": "https://kube-apiserver:6443/openid/v1/jwks" }For this setup,
jwks_uricarries an explicit:6443. With endpoint verification enabled and thumbprints registered,AssumeRoleWithWebIdentityfails at the thumbprint check because RGW tries to resolvekube-apiserver:6443as a hostname.The JWKS download itself (
RGWHTTPTransceiver, curl) handles the port correctly. The failure is in the separate certificate check. Users connecting directly to a provider on a non-default port cannot enable that check and may have to leavergw_enable_jwks_url_verificationoff, which is its default value.Fix
rgw::parse_url_host_port()next to the existing Boost.URL helpers inrgw_url.ccand use it inverify_oidc_thumbprint(), with a default port of 443. Ajwks_urithat does not parse now fails verification with a log message instead of proceeding to DNS lookup.getaddrinfo()instead of the IPv4-onlygethostbyname(), trying each returned address so IPv6 literals and AAAA records work too.get_top_level_domain_from_host(), which has no other caller.Behaviour for a
jwks_uriwithout an explicit port, served on 443, is unchanged.Tests
unittest_rgw_urlgains six cases for the new parser covering the default port, an explicit port, explicit 443, an IPv6 literal with a port, userinfo and invalid inputs. All 20 tests pass. Also compiledrgw_rest_sts.ccwith the existing build dependencies.The connection and thumbprint functions were exercised standalone against a local TLS server on ports 443 and 6443 over IPv4 and IPv6. Matching and non-matching thumbprints, a closed port and an unparsable URL behaved as expected. The pre-patch code fails the same setup with
gethostbyname failed for host: localhost:6443. The local build hasWITH_RADOSGW=OFF, so the fullrgw_commonbuild still needs CI.Fixes: https://tracker.ceph.com/issues/74001
Checklist