I am trying to encode a JWT with python, I need to encode it in base64, with i did. and then I have to sign it with a private key before sending to the server. actually I am blocked, when to sign it I don't know how, I am searching on the web since yesterday, I am little bit lost. here is my code.
import jwt
print ("\nStart..")
encoded = jwt.encode({'some': 'payload'}, 'secret', algorithm='HS256')
print("\nJWT : ",encoded)
try:
decoded = jwt.decode(encoded, 'secret', algorithms=['HS256'])
except jwt.InvalidTokenError:
print("Invalid token!!")
print("\ndecoded : ", decoded)
print("\nencodage : ")
#LOAD THE PRIVATE KEY
#SIGN THE ENCODED token
and there is the format of my key, it is an RSA private key.
-----BEGIN RSA PRIVATE KEY-----
dsjkfhsdfkshkdfhks...
-----END RSA PRIVATE KEY-----
I gave a certificate to the server crt.crt, i think i need to encrypt with my private key, and then they will be able to decrypt the message, with a key from the certificate, that is what i understood.
Thanks in advance, G. B