Repository: certbot/certbot

Issue:
cryptography==0.8 breaks client
Follow-up from https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=203405#c17. It seems that our `cryptography>=0.8` requirement is too weak. After `pip install cryptography==0.8` the following error is thrown:

```
Traceback (most recent call last):
  File "/root/letsencrypt/venv/bin/letsencrypt", line 9, in <module>
    load_entry_point('letsencrypt==0.1.0.dev0', 'console_scripts', 'letsencrypt')()
  File "/root/letsencrypt/letsencrypt/cli.py", line 1002, in main
    return args.func(args, config, plugins)
  File "/root/letsencrypt/letsencrypt/cli.py", line 376, in auth
    le_client = _init_le_client(args, config, authenticator, installer)
  File "/root/letsencrypt/letsencrypt/cli.py", line 160, in _init_le_client
    acc, acme = _determine_account(args, config)
  File "/root/letsencrypt/letsencrypt/cli.py", line 147, in _determine_account
    config, account_storage, tos_cb=_tos_cb)
  File "/root/letsencrypt/letsencrypt/client.py", line 98, in register
    acc = account.Account(regr, key)
  File "/root/letsencrypt/letsencrypt/account.py", line 60, in __init__
    format=serialization.PublicFormat.SubjectPublicKeyInfo)
  File "/root/letsencrypt/venv/local/lib/python2.7/site-packages/cryptography/hazmat/backends/openssl/rsa.py", line 614, in public_bytes
    self._rsa_cdata
  File "/root/letsencrypt/venv/local/lib/python2.7/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 1199, in _public_key_bytes
    raise ValueError("Only PEM encoding is supported by this backend")
ValueError: Only PEM encoding is supported by this backend
```

cryptography==0.8 breaks client
Follow-up from https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=203405#c17. It seems that our `cryptography>=0.8` requirement is too weak. After `pip install cryptography==0.8` the following error is thrown:

```
Traceback (most recent call last):
  File "/root/letsencrypt/venv/bin/letsencrypt", line 9, in <module>
    load_entry_point('letsencrypt==0.1.0.dev0', 'console_scripts', 'letsencrypt')()
  File "/root/letsencrypt/letsencrypt/cli.py", line 1002, in main
    return args.func(args, config, plugins)
  File "/root/letsencrypt/letsencrypt/cli.py", line 376, in auth
    le_client = _init_le_client(args, config, authenticator, installer)
  File "/root/letsencrypt/letsencrypt/cli.py", line 160, in _init_le_client
    acc, acme = _determine_account(args, config)
  File "/root/letsencrypt/letsencrypt/cli.py", line 147, in _determine_account
    config, account_storage, tos_cb=_tos_cb)
  File "/root/letsencrypt/letsencrypt/client.py", line 98, in register
    acc = account.Account(regr, key)
  File "/root/letsencrypt/letsencrypt/account.py", line 60, in __init__
    format=serialization.PublicFormat.SubjectPublicKeyInfo)
  File "/root/letsencrypt/venv/local/lib/python2.7/site-packages/cryptography/hazmat/backends/openssl/rsa.py", line 614, in public_bytes
    self._rsa_cdata
  File "/root/letsencrypt/venv/local/lib/python2.7/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 1199, in _public_key_bytes
    raise ValueError("Only PEM encoding is supported by this backend")
ValueError: Only PEM encoding is supported by this backend
```



Discussion:

Resolving patch:
diff --git a/letsencrypt/account.py b/letsencrypt/account.py
--- a/letsencrypt/account.py
+++ b/letsencrypt/account.py
@@ -56,7 +56,7 @@ def __init__(self, regr, key, meta=None):
 
         self.id = hashlib.md5(
             self.key.key.public_key().public_bytes(
-                encoding=serialization.Encoding.DER,
+                encoding=serialization.Encoding.PEM,
                 format=serialization.PublicFormat.SubjectPublicKeyInfo)
         ).hexdigest()
         # Implementation note: Email? Multiple accounts can have the


Test patch:
diff --git a/letsencrypt/tests/account_test.py b/letsencrypt/tests/account_test.py
--- a/letsencrypt/tests/account_test.py
+++ b/letsencrypt/tests/account_test.py
@@ -45,16 +45,16 @@ def test_init(self):
 
     def test_id(self):
         self.assertEqual(
-            self.acc.id, "2ba35a3bdf380ed76a5ac9e740568395")
+            self.acc.id, "bca5889f66457d5b62fbba7b25f9ab6f")
 
     def test_slug(self):
         self.assertEqual(
-            self.acc.slug, "test.letsencrypt.org@2015-07-04T14:04:10Z (2ba3)")
+            self.acc.slug, "test.letsencrypt.org@2015-07-04T14:04:10Z (bca5)")
 
     def test_repr(self):
         self.assertEqual(
             repr(self.acc),
-            "<Account(2ba35a3bdf380ed76a5ac9e740568395)>")
+            "<Account(bca5889f66457d5b62fbba7b25f9ab6f)>")
 
 
 class ReportNewAccountTest(unittest.TestCase):