@@ -577,9 +577,14 @@ WebTokenEngine::validate_signature_using_n_e(const DoutPrefixProvider* dpp, cons
577577 return true ;
578578}
579579
580- bool WebTokenEngine::validate_cert_url (const DoutPrefixProvider* dpp, const std::string& cert_url,
580+ bool WebTokenEngine::verify_oidc_thumbprint (const DoutPrefixProvider* dpp, const std::string& cert_url,
581581 const std::vector<std::string>& thumbprints) const
582582{
583+ if (!cct->_conf .get_val <bool >(" rgw_enable_jwks_url_verification" )) {
584+ ldpp_dout (dpp, 5 ) << " Verification of JWKS endpoint is turned off." << dendl;
585+ return true ;
586+ }
587+
583588 // Fetch and verify cert according to https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_oidc_verify-thumbprint.html
584589 const auto hostname = get_top_level_domain_from_host (dpp, cert_url);
585590 ldpp_dout (dpp, 20 ) << " Validating hostname: " << hostname << dendl;
@@ -606,7 +611,7 @@ WebTokenEngine::validate_signature(const DoutPrefixProvider* dpp, const jwt::dec
606611{
607612 if (algorithm != " HS256" && algorithm != " HS384" && algorithm != " HS512" ) {
608613 const auto cert_url = get_cert_url (iss, dpp, y);
609- if (cert_url.empty () || !validate_cert_url (dpp, cert_url, thumbprints)) {
614+ if (cert_url.empty () || !verify_oidc_thumbprint (dpp, cert_url, thumbprints)) {
610615 ldpp_dout (dpp, 5 ) << " Not able to validate JWKS url with registered thumbprints" << dendl;
611616 throw std::system_error (EINVAL, std::system_category ());
612617 }
@@ -646,10 +651,11 @@ WebTokenEngine::validate_signature(const DoutPrefixProvider* dpp, const jwt::dec
646651 if (JSONDecoder::decode_json (" x5c" , x5c, &k_parser)) {
647652 string cert;
648653 bool found_valid_cert = false ;
654+ bool skip_thumbprint_verification = cct->_conf .get_val <bool >(" rgw_enable_jwks_url_verification" );
649655 for (auto & it : x5c) {
650656 cert = " -----BEGIN CERTIFICATE-----\n " + it + " \n -----END CERTIFICATE-----" ;
651657 ldpp_dout (dpp, 20 ) << " Certificate is: " << cert.c_str () << dendl;
652- if (is_cert_valid (thumbprints, cert)) {
658+ if (skip_thumbprint_verification || is_cert_valid (thumbprints, cert)) {
653659 found_valid_cert = true ;
654660 break ;
655661 }
@@ -737,7 +743,7 @@ WebTokenEngine::validate_signature(const DoutPrefixProvider* dpp, const jwt::dec
737743 return ;
738744 }
739745 }
740- ldpp_dout (dpp, 10 ) << " Bare key parameters are not present for key" << dendl;
746+ ldpp_dout (dpp, 10 ) << " Bare key parameters (n&e) are not present for key" << dendl;
741747 }
742748 }
743749 } // end k_parser.parse
0 commit comments