Repository: certbot/certbot

Issue:
renew: letsencrypt.client:Registering without email!
I succesfully set up a certificate for https://turbolab.it/ (CentOS 6.7 with Apache 2.2) like this:

```
git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
cd /opt/letsencrypt
./letsencrypt-auto certonly --webroot -w /full/site/path/ -d turbolab.it -d www.turbolab.it
```

I provided my email + agreed to TOS from the _graphic_ (blue) UI.

**Now I'm trying to stage the cert renewal but I'm facing issue**. When I try to renew with `./letsencrypt-auto renew --dry-run` I get:

```
[root@skycracker letsencrypt]# ./letsencrypt-auto renew --dry-run
Checking for new version...
Creating virtual environment...
Installing Python packages...
Installation succeeded.
Requesting root privileges to run letsencrypt...
   /root/.local/share/letsencrypt/bin/letsencrypt renew --dry-run
/root/.local/share/letsencrypt/lib/python2.6/site-packages/cryptography/__init__.py:26: DeprecationWarning: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of cryptography will drop support for Python 2.6
  DeprecationWarning
Processing /etc/letsencrypt/renewal/turbolab.it.conf
2016-04-02 13:49:45,115:WARNING:letsencrypt.client:Registering without email!
2016-04-02 13:49:45,910:WARNING:letsencrypt.cli:Attempting to renew cert from /etc/letsencrypt/renewal/turbolab.it.conf produced an unexpected error: Missing command line flag or config entry for this setting:
Please read the Terms of Service at https://letsencrypt.org/documents/LE-SA-v1.0.1-July-27-2015.pdf. You must agree in order to register with the ACME server at https://acme-staging.api.letsencrypt.org/directory

(You can set this with the --agree-tos flag). Skipping.
** DRY RUN: simulating 'letsencrypt renew' close to cert expiry
**          (The test certificates below have not been saved.)

All renewal attempts failed. The following certs could not be renewed:
  /etc/letsencrypt/live/turbolab.it/fullchain.pem (failure)
** DRY RUN: simulating 'letsencrypt renew' close to cert expiry
**          (The test certificates above have not been saved.)
1 renew failure(s), 0 parse failure(s)
```

The `DeprecationWarning` makes me very uncomfortable, but I understood shouldn't be an issue.

The failure is the real issue here. I understood that the `renew` parameter should fire a renew with the same options used at install-time, so why the failure?

Thanks!

Update: I can confirm that `/etc/letsencrypt/renewal/turbolab.it.conf` holds the correct setting `
email = info@ MY SITE`



Discussion:

Resolving patch:
diff --git a/letsencrypt/cli.py b/letsencrypt/cli.py
--- a/letsencrypt/cli.py
+++ b/letsencrypt/cli.py
@@ -339,7 +339,7 @@ def parse_args(self):
                 if glob.glob(os.path.join(parsed_args.config_dir, constants.ACCOUNTS_DIR, "*")):
                     # The user has a prod account, but might not have a staging
                     # one; we don't want to start trying to perform interactive registration
-                    parsed_args.agree_tos = True
+                    parsed_args.tos = True
                     parsed_args.register_unsafely_without_email = True
 
         if parsed_args.csr:
diff --git a/letsencrypt/client.py b/letsencrypt/client.py
--- a/letsencrypt/client.py
+++ b/letsencrypt/client.py
@@ -105,7 +105,8 @@ def register(config, account_storage, tos_cb=None):
                    "--register-unsafely-without-email was not present.")
             logger.warn(msg)
             raise errors.Error(msg)
-        logger.warn("Registering without email!")
+        if not config.dry_run:
+            logger.warn("Registering without email!")
 
     # Each new registration shall use a fresh new key
     key = jose.JWKRSA(key=jose.ComparableRSAKey(


Test patch:
diff --git a/letsencrypt/tests/cli_test.py b/letsencrypt/tests/cli_test.py
--- a/letsencrypt/tests/cli_test.py
+++ b/letsencrypt/tests/cli_test.py
@@ -427,20 +427,40 @@ def test_staging_flag(self):
         short_args += '--server example.com'.split()
         self._check_server_conflict_message(short_args, '--staging')
 
-    def _assert_dry_run_flag_worked(self, namespace):
+    def _assert_dry_run_flag_worked(self, namespace, existing_account):
         self.assertTrue(namespace.dry_run)
         self.assertTrue(namespace.break_my_certs)
         self.assertTrue(namespace.staging)
         self.assertEqual(namespace.server, constants.STAGING_URI)
 
+        if existing_account:
+            self.assertTrue(namespace.tos)
+            self.assertTrue(namespace.register_unsafely_without_email)
+        else:
+            self.assertFalse(namespace.tos)
+            self.assertFalse(namespace.register_unsafely_without_email)
+
     def test_dry_run_flag(self):
         parse = self._get_argument_parser()
-        short_args = ['--dry-run']
+        config_dir = tempfile.mkdtemp()
+        short_args = '--dry-run --config-dir {0}'.format(config_dir).split()
         self.assertRaises(errors.Error, parse, short_args)
 
-        self._assert_dry_run_flag_worked(parse(short_args + ['auth']))
+        self._assert_dry_run_flag_worked(
+            parse(short_args + ['auth']), False)
+        self._assert_dry_run_flag_worked(
+            parse(short_args + ['certonly']), False)
+        self._assert_dry_run_flag_worked(
+            parse(short_args + ['renew']), False)
+
+        account_dir = os.path.join(config_dir, constants.ACCOUNTS_DIR)
+        os.mkdir(account_dir)
+        os.mkdir(os.path.join(account_dir, 'fake_account_dir'))
+
+        self._assert_dry_run_flag_worked(parse(short_args + ['auth']), True)
+        self._assert_dry_run_flag_worked(parse(short_args + ['renew']), True)
         short_args += ['certonly']
-        self._assert_dry_run_flag_worked(parse(short_args))
+        self._assert_dry_run_flag_worked(parse(short_args), True)
 
         short_args += '--server example.com'.split()
         conflicts = ['--dry-run']
diff --git a/letsencrypt/tests/client_test.py b/letsencrypt/tests/client_test.py
--- a/letsencrypt/tests/client_test.py
+++ b/letsencrypt/tests/client_test.py
@@ -80,6 +80,7 @@ def test_without_email(self, mock_logger):
             with mock.patch("letsencrypt.account.report_new_account"):
                 self.config.email = None
                 self.config.register_unsafely_without_email = True
+                self.config.dry_run = False
                 self._call()
                 mock_logger.warn.assert_called_once_with(mock.ANY)