You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to use a JWK inside a block in JWT.decode, since I cannot use the jwks option because (for backwards compatibility reasons) I need a special handling of the situation where no kid is present in the token header (I.e. if the issuer only has one key, use that one).
When trying to get the public key from a JWT::JWK using .public_key, its usability depends on the kty.
For RSA and in particular OpenSSL::PKey::RSA, you get another OpenSSL::PKey::RSA object, for which .private? returns false.
For EC and in particular OpenSSL::PKey::EC, you get a OpenSSL::PKey::EC::Point.
This seems unexpected and causes the validation to fail for EC, since a Point has no method dsa_verify_asn1 used in the EC Algo.
For me, using .keypair instead solved the issue but always exporting the private key as well seems like a bad habit.
Should JWT::JWK::EC#public_key return OpenSSL::PKey::EC even though OpenSSL::PKey::EC#public_key does not?
The text was updated successfully, but these errors were encountered:
bellebaum
changed the title
JWT::JWK::EC.public_key returns unexpected type
JWT::JWK::EC#public_key returns unexpected type
Oct 21, 2022
Hey,
I was trying to use a JWK inside a block in
JWT.decode
, since I cannot use thejwks
option because (for backwards compatibility reasons) I need a special handling of the situation where nokid
is present in the token header (I.e. if the issuer only has one key, use that one).When trying to get the public key from a
JWT::JWK
using.public_key
, its usability depends on thekty
.For
RSA
and in particularOpenSSL::PKey::RSA
, you get anotherOpenSSL::PKey::RSA
object, for which.private?
returnsfalse
.For
EC
and in particularOpenSSL::PKey::EC
, you get aOpenSSL::PKey::EC::Point
.This seems unexpected and causes the validation to fail for EC, since a Point has no method
dsa_verify_asn1
used in the EC Algo.For me, using
.keypair
instead solved the issue but always exporting the private key as well seems like a bad habit.Should
JWT::JWK::EC#public_key
returnOpenSSL::PKey::EC
even thoughOpenSSL::PKey::EC#public_key
does not?The text was updated successfully, but these errors were encountered: