任何人都可以在没有密钥的情况下解码 JSON Web 令牌 (JWT) 吗?
Can anybody decode a JSON Web Token (JWT) without a secret key?
我是这个领域的新手,但我正在尝试使用 JWT nuget package.
生成 JWT
我的理解是你提供了一个密钥来签署令牌,但是当我得到令牌后我去 JWT website 测试它并且网站能够在我不提供密钥的情况下解码它。
我认为您生成令牌然后对其进行签名,从而防止任何人知道令牌的内容,除非他们拥有该密钥。不是这样吗?
JSON Web 令牌是数据结构的编码表示。不需要加密此编码数据,但这样做是可以接受的。
来自代码签名的定义:
Code signing is the process of digitally signing executables and scripts to confirm the software author and guarantee that the code has not been altered or corrupted since it was signed by use of a cryptographic hash.
经过加密的 JWT 通常会有两个哈希值,第一个用于解密数据,第二个用于验证代码签名。解码未加密的 JWT 是一个标准化过程,即使未验证代码签名也可以完成。但是,如果代码签名哈希不匹配,建议不要在 JWT 中使用任何数据,因为这表明数据可能已被篡改。
并非所有 JWT 实现都支持加密;值得注意的是,Microsoft 的 JWT 实现中没有加密支持。 . Therefore, if you have data which you must ensure remains secret, you should encrypt the data using JWE. The JWT standards documentation shows an example of this process。数据首先被加密,然后加密的字符串和解码算法作为 JWT 的负载发送。
我是这个领域的新手,但我正在尝试使用 JWT nuget package.
生成 JWT我的理解是你提供了一个密钥来签署令牌,但是当我得到令牌后我去 JWT website 测试它并且网站能够在我不提供密钥的情况下解码它。
我认为您生成令牌然后对其进行签名,从而防止任何人知道令牌的内容,除非他们拥有该密钥。不是这样吗?
JSON Web 令牌是数据结构的编码表示。不需要加密此编码数据,但这样做是可以接受的。
来自代码签名的定义:
Code signing is the process of digitally signing executables and scripts to confirm the software author and guarantee that the code has not been altered or corrupted since it was signed by use of a cryptographic hash.
经过加密的 JWT 通常会有两个哈希值,第一个用于解密数据,第二个用于验证代码签名。解码未加密的 JWT 是一个标准化过程,即使未验证代码签名也可以完成。但是,如果代码签名哈希不匹配,建议不要在 JWT 中使用任何数据,因为这表明数据可能已被篡改。
并非所有 JWT 实现都支持加密;值得注意的是,Microsoft 的 JWT 实现中没有加密支持。 . Therefore, if you have data which you must ensure remains secret, you should encrypt the data using JWE. The JWT standards documentation shows an example of this process。数据首先被加密,然后加密的字符串和解码算法作为 JWT 的负载发送。