I have a my_key.p12
file, password-protected. I extracted the key with
openssl pkcs12 -in my_key.p12 -out my_key.key -nocerts -nodes -passin pass:<password>
Now I'm trying to sign a JWT with python using pyjwt, but no matter what I try I get errors.
A simple
private_key_file = Path(f"my_key.key")
encoded = jwt.encode({"some": "payload"}, private_key_file.read_bytes(), algorithm="RS256")
returns an exception (see https://github.com/jpadilla/pyjwt/issues/717). Note that this example is taken straight out of the docs.
Does anyone know how exactly someone is supposed to encode a JWT in python with a p12 file, or in any case using the algorithm RS256, if I must convert the p12 file to an intermediate key type?