已经有解密密钥和signed_key ..只需要知道python中哪个库是解码由这个Java算法创建的JWT令牌的正确库
JWE加密:算法:RSA_OAEP,加密A128GCM 令牌签名:算法:RS256
decrypt.py文件:
from jwcrypto import jwt, jwk
k = {"n": G_DECRYPTION_KEY, "kty": "RSA", "e":"A128GCM"} #, "alg":"RS256"} # "e":"AQAB"
print 'k : %s \n'% k
key = jwk.JWK(**k)
print 'key : %s \n'% key
decrypted_key = jwt.JWT(key=key, jwt= g_token)
print 'decrypted_key : %s \n'% decrypted_key
signed_key = jwt.JWT(key=key, jwt=decrypted_key.claims)
print 'signed_key : %s'% signed_key
signed_key.claims
print 'signed_key.claims %s
'
我收到错误:
decrypted_key = jwt.JWT(key=key, jwt= g_token)
File "C:\Python27\lib\site-packages\jwcrypto\jwt.py", line 204, in __init__
self.deserialize(jwt, key)
File "C:\Python27\lib\site-packages\jwcrypto\jwt.py", line 460, in deserialize
self.token.deserialize(jwt, key)
File "C:\Python27\lib\site-packages\jwcrypto\jwe.py", line 472, in deserialize
self.decrypt(key)
File "C:\Python27\lib\site-packages\jwcrypto\jwe.py", line 399, in decrypt
'key' + repr(self.decryptlog))
InvalidJWEData: No recipient matched the provided key["Failed: [KeyError('p',)]"]
答案 0 :(得分:0)
确保您的解密密钥与加密密钥相同。而且我相信两个密钥都应该是HttpClientBuilder
包中RequestConfig
的实例