adafruit / adafruit/Adafruit_CircuitPython_JWT

The key generation example in this repo is not working any more

Open
#18 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
7
Forks
7
PR merge metrics
No merged PRs in 30d

Description

It raises this exception:
```
writing RSA key
Traceback (most recent call last):
File "Adafruit_CircuitPython_JWT/examples/jwt_simpletest_secrets.py", line 37, in
pk = rsa.PrivateKey.load_pkcs1(private_key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".cpy_venv/lib/python3.12/site-packages/rsa/key.py", line 125, in load_pkcs1
return method(keyfile)
^^^^^^^^^^^^^^^
File ".cpy_venv/lib/python3.12/site-packages/rsa/key.py", line 612, in _load_pkcs1_pem
der = rsa.pem.load_pem(keyfile, b"RSA PRIVATE KEY")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".cpy_venv/lib/python3.12/site-packages/rsa/pem.py", line 103, in load_pem
pem_lines = [line for line in _pem_lines(contents, pem_start, pem_end)]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".cpy_venv/lib/python3.12/site-packages/rsa/pem.py", line 77, 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 private key that was generated begins with `-----BEGIN PRIVATE KEY-----`, note the lack of "RSA". I'm guessing that my version of openssl is newer than what this example or the library it uses were written for.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with examples/jwt_simpletest_secrets.py at line 37 and inspect how the generated private key is loaded. Reproduce the failure and compare the generated PEM header with the format expected by rsa.PrivateKey.load_pkcs1; done means the example can load the generated key without the PEM marker exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
authentication
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.