fix: use PKCS8 by default for ID token verify #466
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is (hopefully) a fix for #457.
It happens specifically with phpseclib 3.x.
When using the
AccessToken
class to decode an ID token, the "Federated Sign On" certificates are stored in the PKCS8 format after which the ID token is decoded withFirebase/JWT
:Source: AccessToken.php#L246
Part of decoding the JWT is verifying the token which happens with
openssl_verify
:Source: JWT.php#L306
I have to be honest that I am completely lacking any knowledge about RSA keys and their encoding, but according to this StackOverflow issue PHP OpenSSL only accepts "public key in X.509 style". I can confirm this as I am getting the error "Supplied key param cannot be coerced into a public key" (same as in the linked issue at the start of this comment). After returning the key in PKCS8 format, the issue was fixed.
I understand my assessment of the issue might be completely wrong but I really like to help resolve this issue! 👍