JWT 标头在版本 23.3.0 上给出错误“OpenSSL.crypto.Error: [('asn1 编码例程', '', '非法零内容')]”,但适用于早期版本

问题描述 投票:0回答:1

我最近将 python/conda 更新到了 3.11。其中包括新版本的 OpenSSL。下面的代码在 1.1.1 版本上运行了一段时间,但现在在 3.0.1 版本中,kid 行出现错误。是否有新的语法或需要传递的另一个参数?一如既往,非常感谢任何帮助。

from OpenSSL import crypto
headers = {'alg': 'RS256',
                             # this is the line that throws the error
           'kid': crypto.X509().digest('sha1').decode('utf-8').replace(':', ''), 
           'typ': 'JWT',
           }

如果需要更多代码,请告诉我

再次感谢!

python pyopenssl
1个回答
0
投票

注释掉“kid”行,jwt 仍被接收端接受并生成必要的令牌。我还必须将我的 pyjwt 包从 2.4.0 更新到 2.8.0。

© www.soinside.com 2019 - 2024. All rights reserved.