@@ -191,14 +191,12 @@ static apr_byte_t oidc_proto_endpoint_auth_private_key_jwt(request_rec *r, oidc_
191191 return FALSE;
192192
193193 if ((client_keys != NULL ) && (client_keys -> nelts > 0 )) {
194- jwk = oidc_util_key_list_first (client_keys , CJOSE_JWK_KTY_RSA , OIDC_JOSE_JWK_SIG_STR );
194+ jwk = oidc_util_key_list_first (client_keys , -1 , OIDC_JOSE_JWK_SIG_STR );
195195 if (jwk && jwk -> x5t )
196196 jwt -> header .x5t = apr_pstrdup (r -> pool , jwk -> x5t );
197197 } else if ((oidc_cfg_private_keys_get (cfg ) != NULL ) && (oidc_cfg_private_keys_get (cfg )-> nelts > 0 )) {
198- jwk =
199- oidc_util_key_list_first (oidc_cfg_private_keys_get (cfg ), CJOSE_JWK_KTY_RSA , OIDC_JOSE_JWK_SIG_STR );
200- jwk_pub =
201- oidc_util_key_list_first (oidc_cfg_public_keys_get (cfg ), CJOSE_JWK_KTY_RSA , OIDC_JOSE_JWK_SIG_STR );
198+ jwk = oidc_util_key_list_first (oidc_cfg_private_keys_get (cfg ), -1 , OIDC_JOSE_JWK_SIG_STR );
199+ jwk_pub = oidc_util_key_list_first (oidc_cfg_public_keys_get (cfg ), -1 , OIDC_JOSE_JWK_SIG_STR );
202200 if (jwk_pub && jwk_pub -> x5t )
203201 // populate x5t; at least required for Microsoft Entra ID / Azure AD
204202 jwt -> header .x5t = apr_pstrdup (r -> pool , jwk_pub -> x5t );
@@ -212,7 +210,8 @@ static apr_byte_t oidc_proto_endpoint_auth_private_key_jwt(request_rec *r, oidc_
212210 }
213211
214212 jwt -> header .kid = apr_pstrdup (r -> pool , jwk -> kid );
215- jwt -> header .alg = apr_pstrdup (r -> pool , CJOSE_HDR_ALG_RS256 );
213+ jwt -> header .alg =
214+ apr_pstrdup (r -> pool , jwk -> kty == CJOSE_JWK_KTY_EC ? CJOSE_HDR_ALG_ES256 : CJOSE_HDR_ALG_RS256 );
216215
217216 oidc_proto_jwt_sign_and_add (r , params , jwt , jwk );
218217
0 commit comments