Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoding must be an item from encoding enum #3503

Closed
whitj00 opened this issue Sep 16, 2016 · 18 comments
Closed

Encoding must be an item from encoding enum #3503

whitj00 opened this issue Sep 16, 2016 · 18 comments

Comments

@whitj00
Copy link

whitj00 commented Sep 16, 2016

I get this issue on ubuntu 16.04 with apache

Traceback (most recent call last):
File "/usr/bin/letsencrypt", line 9, in
load_entry_point('letsencrypt==0.4.1', 'console_scripts', 'letsencrypt')()
File "/usr/lib/python2.7/dist-packages/letsencrypt/cli.py", line 1986, in main
return config.func(config, plugins)
File "/usr/lib/python2.7/dist-packages/letsencrypt/cli.py", line 660, in run
le_client = _init_le_client(config, authenticator, installer)
File "/usr/lib/python2.7/dist-packages/letsencrypt/cli.py", line 206, in _init_le_client
acc, acme = _determine_account(config)
File "/usr/lib/python2.7/dist-packages/letsencrypt/cli.py", line 191, in _determine_account
config, account_storage, tos_cb=_tos_cb)
File "/usr/lib/python2.7/dist-packages/letsencrypt/client.py", line 127, in register
acc = account.Account(regr, key)
File "/usr/lib/python2.7/dist-packages/letsencrypt/account.py", line 60, in init
format=serialization.PublicFormat.SubjectPublicKeyInfo)
File "/usr/lib/python2.7/dist-packages/cryptography/hazmat/backends/openssl/rsa.py", line 604, in public_bytes
self._rsa_cdata
File "/usr/lib/python2.7/dist-packages/cryptography/hazmat/backends/openssl/backend.py", line 2208, in _public_key_bytes
raise TypeError("encoding must be an item from the Encoding enum")
TypeError: encoding must be an item from the Encoding enum

@Dunky13
Copy link

Dunky13 commented Oct 2, 2016

I have the same problem...

@dollarklavs
Copy link

Same setup and same problem for me.

@Dunky13
Copy link

Dunky13 commented Nov 2, 2016

Bump?

@thijskh
Copy link

thijskh commented Nov 19, 2016

I had this on debian-jessie and it was the result of some wrong package combination, possibly related to backports. Because I was a bit in a hurry I removed certbot and all its python-* dependencies completely, and then freshly installed it all with apt. Sorry that I was not able to pinpoint it further, but maybe this helps someone.

@Dunky13
Copy link

Dunky13 commented Nov 23, 2016

Tried the same thing, accidentally removed all my certificates and ssl options... Crap... Had to re-install every certificate, but again I got the enum error. Somehow I had a working certbot-auto stored in my home directory that did work. Nonetheless it still doesn't work properly for me

@Dunky13
Copy link

Dunky13 commented Dec 17, 2016

Bump?

@pde
Copy link
Member

pde commented Dec 19, 2016

These kinds of errors are usually caused by a mismatch between the versions of python-cryptography and openssl / libssl on your system. However in this case it looks like you might be using the Xenial packages for all of those things, which makes this a little unusual. Was there a recent Xenial update to either libssl or python-cryptography?

@Dunky13
Copy link

Dunky13 commented Dec 19, 2016

For me what seems to be working is the certbot-auto that seems comparable to the letsencrypt-auto in the master gist repository. But the certbot that must load sub code doesn't.

Hope this helps?

@alex
Copy link
Collaborator

alex commented Dec 19, 2016

This wouldn't be caused by the openssl package, this is something specific to cryptography itself, and I really have no idea beyond that.

@reaperhulk
Copy link
Collaborator

This error arises from an isinstance check that looks for a member of a specific enum. If (somehow, bear with me this is gonna be hand-wavey) the enum it was looking for and the enum passed were from different versions of cryptography that were somehow both loaded that could account for this issue...

@alex
Copy link
Collaborator

alex commented Feb 23, 2017

Is there any more info here about a way to reproduce this?

@castaway
Copy link

Ditto for me on gentoo, just updated both python cryptography and openssl, which made it do something different.. briedy it instead said SysCallError: (104, 'ECONNRESET')... and then went back to the enum error.. :(

@Thynix
Copy link

Thynix commented Jul 11, 2017

Same issue on Debian Stretch:

  • apache 2.4.25
  • certbot 0.10.2-1
  • python-certbot-apache 0.10.2-1
  • python-cryptography 1.7.1-3

As of this writing these packages are all up-to-date. This box was upgraded from Debian Jessie, where I used the jessie-backports version, and might have also used a more manual installation method earlier: I had an outdated zope.interface installed with pip,

@0b01
Copy link

0b01 commented Jul 21, 2017

same issue here

@reissmann
Copy link

reissmann commented May 3, 2018

same issue, Debian 9.4, certbot 0.24.0

Traceback (most recent call last):
  File "/usr/local/bin/certbot", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/certbot/main.py", line 1315, in main
    return config.func(config, plugins)
  File "/usr/local/lib/python2.7/dist-packages/certbot/main.py", line 1072, in run
    le_client = _init_le_client(config, authenticator, installer)
  File "/usr/local/lib/python2.7/dist-packages/certbot/main.py", line 637, in _init_le_client
    acc, acme = _determine_account(config)
  File "/usr/local/lib/python2.7/dist-packages/certbot/main.py", line 491, in _determine_account
    accounts = account_storage.find_all()
  File "/usr/local/lib/python2.7/dist-packages/certbot/account.py", line 168, in find_all
    accounts.append(self.load(account_id))
  File "/usr/local/lib/python2.7/dist-packages/certbot/account.py", line 189, in load
    acc = Account(regr, key, meta)
  File "/usr/local/lib/python2.7/dist-packages/certbot/account.py", line 62, in __init__
    format=serialization.PublicFormat.SubjectPublicKeyInfo)
  File "/usr/lib/python2.7/dist-packages/cryptography/hazmat/backends/openssl/rsa.py", line 514, in public_bytes
    self._rsa_cdata
  File "/usr/lib/python2.7/dist-packages/cryptography/hazmat/backends/openssl/backend.py", line 1694, in _public_key_bytes
    raise TypeError("encoding must be an item from the Encoding enum")
TypeError: encoding must be an item from the Encoding enum

@dieudv
Copy link

dieudv commented May 25, 2018

Me too.

  File "/bin/certbot", line 9, in <module>
    load_entry_point('certbot==0.24.0', 'console_scripts', 'certbot')()
  File "/usr/lib/python2.7/site-packages/certbot/main.py", line 1315, in main
    return config.func(config, plugins)
  File "/usr/lib/python2.7/site-packages/certbot/main.py", line 1072, in run
    le_client = _init_le_client(config, authenticator, installer)
  File "/usr/lib/python2.7/site-packages/certbot/main.py", line 637, in _init_le_client
    acc, acme = _determine_account(config)
  File "/usr/lib/python2.7/site-packages/certbot/main.py", line 516, in _determine_account
    config, account_storage, tos_cb=_tos_cb)
  File "/usr/lib/python2.7/site-packages/certbot/client.py", line 168, in register
    acc = account.Account(regr, key)
  File "/usr/lib/python2.7/site-packages/certbot/account.py", line 62, in __init__
    format=serialization.PublicFormat.SubjectPublicKeyInfo)
  File "/usr/lib64/python2.7/site-packages/cryptography/hazmat/backends/openssl/rsa.py", line 514, in public_bytes
    self._rsa_cdata
  File "/usr/lib64/python2.7/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 1693, in _public_key_bytes
    raise TypeError("encoding must be an item from the Encoding enum")
TypeError: encoding must be an item from the Encoding enum

@bmw
Copy link
Member

bmw commented May 9, 2019

It's been almost a year since this issue has seen any activity so I'm closing it. If you're still hitting this, please comment or open a new issue.

@bmw bmw closed this as completed May 9, 2019
@goma1256
Copy link

goma1256 commented Nov 1, 2021

Just for the record and anyone out there, also happened to me using :

  • Python 3.6.1 (using Spyder on Windows 10 - please don't judge)
  • Fresh install of sshtunnel (0.4.0)
  • Cryptography 3.4.7 already installed

Solved by updating Cryptography to 35.0.0 using pip.

Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests