kid of imported PEM keys #24
Replies: 3 comments
-
| 
 thank you 
 There's no corruption, a PEM certificate has all the things necessary to calculate a thumbprint using RFC7638 but it does not have details on the  When importing a  When  so in your aws sample you should do this  | 
Beta Was this translation helpful? Give feedback.
-
| > k = j.JWK.importKey(pem)
RSAKey {
  e: 'AQAB',
  kid: 'Bj1ccHv-y_ZoejJKWhAhBHLpnGSlawNAQUAMEQBd5L8', // calculated because it was missing
  kty: 'RSA',
  n: 'wHsrnJAaDkiGFnplMUi5Grfd4CEPUw9qboum3AhhuOEzf0uw_SOtOfLkkEOxHm5cp8CUNkHtENVK_O0VwF5UXBhetclgEnKf599R9JVWVN1aHEPuEfO29Jbx2k5YqqN7U1WWYPVKIJn_xVNbxhb6gtudSqQGI0ogrSbNb6UIxUILysbRmFN8d25kszDukf0KkssHGpuU8orfknxC8RoL228CRmgNK7o7KaGBLAta9uFeBSzbEHCV6Jn2givW1CfQFSK2npBk_rjsliPzm9D-Pk-DWW-eF1neo8zw7kAkMW0QBnVEYAVYcqxSX42Osl2d0l_KaskavT06unvCzjiRCw'
}
> k.kid
'Bj1ccHv-y_ZoejJKWhAhBHLpnGSlawNAQUAMEQBd5L8'
> k.thumbprint
'Bj1ccHv-y_ZoejJKWhAhBHLpnGSlawNAQUAMEQBd5L8'
> k = j.JWK.importKey(pem, { kid: 'foobar' })
RSAKey {
  e: 'AQAB',
  kid: 'foobar',
  kty: 'RSA',
  n: 'wHsrnJAaDkiGFnplMUi5Grfd4CEPUw9qboum3AhhuOEzf0uw_SOtOfLkkEOxHm5cp8CUNkHtENVK_O0VwF5UXBhetclgEnKf599R9JVWVN1aHEPuEfO29Jbx2k5YqqN7U1WWYPVKIJn_xVNbxhb6gtudSqQGI0ogrSbNb6UIxUILysbRmFN8d25kszDukf0KkssHGpuU8orfknxC8RoL228CRmgNK7o7KaGBLAta9uFeBSzbEHCV6Jn2givW1CfQFSK2npBk_rjsliPzm9D-Pk-DWW-eF1neo8zw7kAkMW0QBnVEYAVYcqxSX42Osl2d0l_KaskavT06unvCzjiRCw'
}
> k.kid
'foobar' // kid that was assigned
> k.thumbprint
'Bj1ccHv-y_ZoejJKWhAhBHLpnGSlawNAQUAMEQBd5L8' // still the calculated thumbprint | 
Beta Was this translation helpful? Give feedback.
-
| Fantastic! Missed that 🚀 | 
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
@panva, first of all, thank you for your amazing work with this library! 👏 👏
I've a got a question:
In my app I've got to decode tokens from multiple issuers, including one for AWS (see: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/listener-authenticate-users.html#user-claims-encoding). The decoded header provides a
kidwhich we use to fetch the public key from a remote server. While most of the issuers return JWKs that match thekidin the token header. E.g.:AWS returns a PEM (PKCS#8) key from the endpoint. When imported, the
kids don't match. E.g.:That means I could not use a
JWKS.KeyStoreto store and verify all tokens as the PEMs keys are never found:Just wanted to understand if this is the expected behaviour or some data corruption (wouldn't be surprised from AWS). I.e. the data in the JWT header being different from the PEM key content but somehow being the correct signature.
Beta Was this translation helpful? Give feedback.
All reactions