mk-fg / acme-cert-tool

Simple one-stop tool to manage X.509/TLS certs and all the ACME CA authorization stuff
Do What The F*ck You Want To Public License
17 stars 10 forks source link

TypeError when checking os.access() #1

Closed johndoe31415 closed 6 years ago

johndoe31415 commented 6 years ago

Hi there,

just tried out acme-cert-tool on Debian Stretch with Python 3.5.3. Unfortunately it doesn't work for me:

$ acme-cert-tool/acme-cert-tool.py --account-key-file account.key account-info
Traceback (most recent call last):
  File "acme-cert-tool/acme-cert-tool.py", line 1002, in <module>
    if __name__ == '__main__': sys.exit(main())
  File "acme-cert-tool/acme-cert-tool.py", line 854, in main
    if not os.access(p_acc_key, os.W_OK):
TypeError: access: illegal type for path parameter

The reason is that acme-cert-tool passes a pathlib.PosixPath instance to os.access(), but at least on my system, os.access() requires a str(). When I add the conversion, it fails in a different place:

$ acme-cert-tool/acme-cert-tool.py --account-key-file account.key account-info
Traceback (most recent call last):
  File "acme-cert-tool/acme-cert-tool.py", line 1002, in <module>
    if __name__ == '__main__': sys.exit(main())
  File "acme-cert-tool/acme-cert-tool.py", line 883, in main
    res = signed_req(acc_key, 'new-reg', payload_reg, acme_url=acme_url)
  File "acme-cert-tool/acme-cert-tool.py", line 271, in signed_req
    acme_dir = json.load(r)
  File "/usr/lib/python3.5/json/__init__.py", line 268, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "/usr/lib/python3.5/json/__init__.py", line 312, in loads
    s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'

So no luck for me unfortunately :-(

All the best to you, Joe

mk-fg commented 6 years ago

I think issue in both cases is python 3.5 - they've changed all os.* funcs to accept paths in 3.6+ and probably same minor type mixup in the case of second error. Wrote/tested the thing with 3.6 (and use mostly 3.7 by now), and it apparently has such incompatibilities with earlier versions.

Shouldn't be hard to adapt it to 3.5, as diffs are kinda minor there, but don't have it anywhere to test or bother with myself, unfortunately. Guess worth adding note on such incompatibility to the README though.

Thanks for bringing it up.