Failure loading RSA public and private keys from file, python

I am having problems using the rsa module in python, I need to load two public and private keys from a file, here is how I can open a private key file, for example:

private_key_file = "privKey.pem" keydata = open(private_key_file).read() privKey = rsa.PrivateKey.load_pkcs1(keydata, 'PEM') 

and I get this error message: ValueError: no PEM trigger token "b" ----- START CLOSED RSA KEY ----- "found

although the contents of the file begin with "----- BEGIN RSA PRIVATE KEY -----" one note is that the file does not contain leading characters b ' . I don’t know where it came from, or whether it matters in this particular problem!

any help would be appreciated

+6
source share

All Articles