-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JWT::createPemFromModulusAndExponent incorrect return value #532
Comments
@libertyit1 did you figure out a fix for this? I seem to be facing the same/similar issue. Could this be related to php/php-src#11054 |
Not in Firebase; I ended up importing phpseclib3 to convert the JWK e & n params into a PKCS8 key and used that in Firebase JWT::decode. |
Hello and thank you for raising this issue. In the official However, I refactored this to use the current oauth2 certs for google at the URL you've provided, and this is working as expected without PHPseclib (see googleapis/google-api-php-client#2596, where I refactor our So, TLDR, you should be able to use this library to verify Google keys without manually coverting to use Firebase\JWT\CachedKeySet;
use Firebase\JWT\JWT;
use Google\Auth\Cache\MemoryCacheItemPool;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\HttpFactory;
$keySet = new CachedKeySet(
'https://www.googleapis.com/oauth2/v3/certs',
new Client(),
new HttpFactory(),
new MemoryCacheItemPool(); // or some other PSR-6 cache
);
$payload = JWT::decode($idToken, $keySet); |
As a matter of interest, what was the bug in JWT::createPemFromModulusAndExponent? I don't see any changes to the code. |
@libertyit1 I never confirmed there was an issue in JWT. The previous workaround (using phpseclib3) we had in the google client library was implemented well before the So, maybe the bug hasn't been fixed, and the keys just got rotated so that it's no longer an issue? I am not really sure. Either way, I can't reproduce it. |
@libertyit1 after some testing, using the values for module, exponent, and public key you provided, I was able to verify that this is parsing the keys as expected. I am not sure what changed to make this the case. See #565 |
I retrieved JWKs for Google public keys from https://www.googleapis.com/oauth2/v3/certs including this one:
JWT::createPemFromModulusAndExponent(n, e) with these values returns this PEM format:
JWTs from Google fail to verify using this key.
phpseclib3
and https://8gwifi.org/jwkconvertfunctions.jsp both return this PEM format:and this key verifies Google JWTs correctly.
The text was updated successfully, but these errors were encountered: