Reputation: 31
So I used the command:
ssh-keygen -m PKCS8 -t dsa
to generate the following (example) key:
-----BEGIN PRIVATE KEY-----
MIIBSgIBADCCASsGByqGSM44BAEwggEeAoGBAIATtp/DhG2hDIT3DiMIctaxPn/s
FFxbXa4IIytk0b/PDBq9Kv/OeFv54h1L9iSLoNHrsx3dOR+6CyFyfnZT9s0yjpSe
uYiU6QVhX1sl24KzlpTXgu2vXlBx24vNq4adGmRROxtxjBaiAlN8va4oM0GT8hNG
sJ6uAWmFfYvqvnulAhUAtuiO7CyAzrkXcneK3qWYntor2w0CgYAYMEDqn+gjIfhx
IcZCA3eTUbuE4xAfzLwz0XSvUbaxYn9bJFmQ17F1vdnD1a4tEy7dyLj1EUNarNUF
P/T/BJdX7P4g+Fua96RuuvUkJ/gFshFBRWgyXyBsvydcZrbYhpSag8jwLo3QAuse
ulTIWyR8BRgYjmmCFIw0uNS86Kyu7wQWAhQtuXafDJ4JWDMpSPHxU+UwzbjfeA==
-----END PRIVATE KEY-----
I am attempting to sign data with this key using the following snippet:
import jwt
with open('./id_dsa', 'r') as file:
key = file.read()
print(key)
token = jwt.encode({'some': 'data'}, key, algorithm='EdDSA')
But I am getting this error:
Traceback (most recent call last):
File "./client.py", line 23, in <module>
token = jwt.encode({'username': args.username,'publicKey': args.pubKey}, key, algorithm='EdDSA')
File "/home/walt/angi/auth/lib/python3.8/site-packages/jwt/api_jwt.py", line 63, in encode
return api_jws.encode(json_payload, key, algorithm, headers, json_encoder)
File "/home/walt/angi/auth/lib/python3.8/site-packages/jwt/api_jws.py", line 114, in encode
signature = alg_obj.sign(signing_input, key)
File "/home/walt/angi/auth/lib/python3.8/site-packages/jwt/algorithms.py", line 578, in sign
return key.sign(msg)
TypeError: sign() missing 1 required positional argument: 'algorithm'
I am not sure if the key I am generating is incorrect or what else I could be doing wrong.
Upvotes: 3
Views: 1259