0
guys, I’m trying to make a project based on:
https://github.com/GoogleCloudPlatform/iot-core-micropython
The problem starts when I get to the decode_rsa.py, in my cmd, I have it:
C:\Users\hyago\Desktop\litlab\teste01micropython>python iot-core-micropython-master\utils\decode_rsa.py
File "iot-core-micropython-master\utils\decode_rsa.py", line 17, in <module>
pk = rsa.PrivateKey.load_pkcs1(private_key)
File "C:\Users\hyago\AppData\Roaming\Python\Python38\site-packages\rsa\key.py", line 116, in load_pkcs1
return method(keyfile)
File "C:\Users\hyago\AppData\Roaming\Python\Python38\site-packages\rsa\key.py", line 563, in _load_pkcs1_pem
der = rsa.pem.load_pem(keyfile, b'RSA PRIVATE KEY')
File "C:\Users\hyago\AppData\Roaming\Python\Python38\site-packages\rsa\pem.py", line 101, in load_pem
pem_lines = [line for line in _pem_lines(contents, pem_start, pem_end)]
File "C:\Users\hyago\AppData\Roaming\Python\Python38\site-packages\rsa\pem.py", line 101, in <listcomp>
pem_lines = [line for line in _pem_lines(contents, pem_start, pem_end)]
File "C:\Users\hyago\AppData\Roaming\Python\Python38\site-packages\rsa\pem.py", line 75, in _pem_lines
raise ValueError('No PEM start marker "%r" found' % pem_start)
ValueError: No PEM start marker "b'-----BEGIN RSA PRIVATE KEY-----'" found
The problem looks like this https://stackoverflow.com/questions/55696799/python-file-is-read-only-after-unit-test-failure#new-Answer
I’m already opening the file as binary 'Rb'
It’s the first time I work with rsa, should be an easy problem, someone can give a strength?
I’m using python 3.8, Windows 10
the code is:
import rsa
with open('C:/Windows/System32/rsa_private.pem','rb') as file:
private_key = file.read()
pk = rsa.PrivateKey.load_pkcs1(private_key)
print(str(pk)[10:])
and the file rsa_private.pem: begins with: -----BEGIN PRIVATE KEY------ Miievwibadanbgkqhkig9w0baqefaascbkkwggslageaaoibaqdrhktmklnhtm3a
...
ends with: -----END PRIVATE KEY-----
My key should be -----BEGIN RSA PRIVATE KEY-----
What can I do, modify the code, the file . pem?