无法使用私钥在 jwt.io 中生成 JWT 令牌

Can't generate a JWT token in jwt.io with Private key

我正在尝试测试我正在构建的关于 JWT 的软件的功能以了解它,它正在使用 Firebase JWT PHP 程序包

我正在尝试创建一个使用密钥对作为 encoding/decoding 的测试用例,但无法获取 http://jwt.io 页面以使用我的密钥创建令牌。

这些是我使用 ssh-keygen 命令创建的密钥,没有任何修改。

我转到页面,select HS256 / 384 / 512 并删除页面默认具有的键。然后我粘贴我的私钥来签署我的数据。但是该页面不会生成任何 JWT。

我做错了什么?

我确实注意到页面中的示例键显示 RSA KEY 并且它们比我的短,这就是我尝试其他 HS* 选项的原因

此外,如果我选择在我的密钥上设置密码,它是否适用于 JWT?

-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
NhAAAAAwEAAQAAAYEA2CAysx8LEzGu3EvWKTf7Yx8N364ifJfW9aJ7brtrg2kAhaBmH2Mw
DO+oo/vl+8fNSON7ADZeo/kjf9XgvDyKxWyCUXIxuFOWKy94tPCwIBJb7YR/tPh3XcMNel
trL/knhhjTnBzTRaApjv2g2kb8JEdn6egfSwhBu/zMjQtkWqLKTO7qZ+b32zaXQvLxiAYl
fL9wKKMqlfRv4Uu6TDzXZDghfSZ3TI5+EITctaLW4wI+suV3xm9zn8+LSnqdkRhXBwWzhU
5CCkWKlMAq6REKsn0V3kyaj582gjlb4zdf/uJc3nWn75uPSl1DhMLT1kgbn6ooQlWo7SlT
vdm2TbScAgLXyPT2RwceTk3vwUc5oZE84jV7YCqrwovnncFk4siBMs/n2pHQac681YtioE
smp3Py1T1PBjTLkqi9Q1q5mSL3RmDY89SKxA6aCbb+uEfwS/qTSYwf6pPR0tXd5JPBoE9d
hfzsYGXegLDAf9XS+GvOcCfRk5DWt4zImMuMChczAAAFiNM40NLTONDSAAAAB3NzaC1yc2
EAAAGBANggMrMfCxMxrtxL1ik3+2MfDd+uInyX1vW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ep2RGFcHBbOFTkIKRYqUwCrpEQqyfRXeTJqPnzaCOVvjN1/+4lzedafvm49KXUOEwtPWSBufqihCVajtKVO92bZNtJwCAtfI9PZHBx5OTe/BRzmhkTziNXtgKqvCi+edwWTiyIEyz+fakdBpzrzVi2KgSyanc/LVPU8GNMuSqL1DWrmZIvdGYNjz1IrEDpoJtv64R/BL+pNJjB/qk9HS1d3kk8GgT12F/OxgZd6AsMB/1dL4a85wJ9GTkNa3jMiYy4wKFzM= jorgee@jorgee

原来密钥必须是PEM格式,不是我的,默认格式。

ssh-keygen -t rsa -b 2048 -m PEM -f mykey.key
# Don't add passphrase
openssl rsa -in mykey.key -pubout -outform PEM -out mykey.pub

私钥示例

-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAqBfiDg2wY5S4ZCx58s2t1f6YjV6bPETX7Ru81loI0rgdDLqS
kEd2JmnxSEQ/7lvPvlMbHGPK0WkhQlBjyiIf8fTAo/Jts+Zh2V1ACBcV72pGyLBc
JGopDO9RYDGK/VNvni4osVb+QXDV9yo/o2fE86KE/yK5K5bz00YW27/C5SjXeJFb
CAdZzjuO02SXYWEJt3poNcew5kavHnUmx8fYr1MdIlvEe+auNArsF0uMz/1StWIx
0u349IQJBoWmtCXrVYStGZNrBvaSFa/MzR+h2XnUbDRnRUfN5drDoIq/qYMXbRoP
wFzLquARuJsHJVhO8+2fNQLt4lgBXFKYC/HX3wIDAQABAoIBADdxKS5ZdYRi2S6x
PMfI7z1V7Bs0yR7n1hBuxaotqBtYfrxkDVNpPp8M8nhTioKj5bFw19BVWeAYPNAS
k9dnygGUKLXqkCR2KG/5QdVpR+LfutkW0k1wdnm9tal0rdNAYeBaeTGE7/fFr80G
MldDMsLpJ9S/LzQhZeqZg5CXf0D13ran7r9ZsaxLBctY0WRYjvMKBCKIQhWWsxXH
Wl4gsTQqra/Ai4cswL2JgJ0YVizVOd9m0uBHBdTvIE+P6+HFgg7cE+wE1HUUrUuO
Gp9eneZCNWSKPykRIKA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