Repository: certbot/certbot

Issue:
<domain> is not a FQDN because label<domain> is too long.
## My operating system is (include version):

` Ubuntu 16.04, all security updates installed `

## I installed Certbot with (certbot-auto, OS package manager, pip, etc):
` Installed it via sudo apt-get install certbot`

## I ran this command and it produced this output:
``` 
sudo certbot -d http://hoeveelmensengaveneeneuroomtezienhoeveelmenseneeneurogaven.nl
Requested domain http://hoeveelmensengaveneeneuroomtezienhoeveelmenseneeneurogaven.nl is not a FQDN because label http://hoeveelmensengaveneeneuroomtezienhoeveelmenseneeneurogaven is too long. 
```

## Certbot's behavior differed from what I expected because:
` The domain name is too long. `


## Here is a Certbot log showing the issue (if available):
###### Logs are stored in `/var/log/letsencrypt` by default. Feel free to redact domains, e-mail and IP addresses as you see fit.
``` ➜  letsencrypt cat letsencrypt.log
2017-06-06 12:19:26,568:DEBUG:certbot.main:certbot version: 0.14.2
2017-06-06 12:19:26,568:DEBUG:certbot.main:Arguments: []
2017-06-06 12:19:26,568:DEBUG:certbot.main:Discovered plugins: PluginsRegistry(PluginEntryPoint#manual,PluginEntryPoint#null,PluginEntryPoint#standalone,PluginEntryPoint#webroot)
2017-06-06 12:19:26,581:DEBUG:certbot.plugins.selection:Requested authenticator <certbot.cli._Default object at 0x7f897d4d8fd0> and installer <certbot.cli._Default object at 0x7f897d4d8fd0>
2017-06-06 12:19:26,581:DEBUG:certbot.cli:Default Detector is Namespace(account=<certbot.cli._Default object at 0x7f897d52ff10>, agree_dev_preview=None, allow_subset_of_names=<certbot.cli._Default object at 0x7f897d534250>, apache=<certbot.cli._Default object at 0x7f897d4dd310>, authenticator=<certbot.cli._Default object at 0x7f897d4d8fd0>, break_my_certs=<certbot.cli._Default object at 0x7f897d547550>, cert_path=<certbot.cli._Default object at 0x7f897d4d87d0>, certname=<certbot.cli._Default object at 0x7f897d53c3d0>, chain_path=<certbot.cli._Default object at 0x7f897d4d8ad0>, checkpoints=<certbot.cli._Default object at 0x7f897d4d82d0>, config_dir=<certbot.cli._Default object at 0x7f897d4d8bd0>, config_file=None, configurator=<certbot.cli._Default object at 0x7f897d4d8fd0>, csr=<certbot.cli._Default object at 0x7f897d4d80d0>, debug=<certbot.cli._Default object at 0x7f897d52f390>, debug_challenges=<certbot.cli._Default object at 0x7f897d547d50>, dialog=None, domains=<certbot.cli._Default object at 0x7f897d53c550>, dry_run=<certbot.cli._Default object at 0x7f897d53c210>, duplicate=<certbot.cli._Default object at 0x7f897d52fd90>, eff_email=<certbot.cli._Default object at 0x7f897d534bd0>, email=<certbot.cli._Default object at 0x7f897d534d50>, expand=<certbot.cli._Default object at 0x7f897d534750>, force_interactive=<certbot.cli._Default object at 0x7f897d53c6d0>, fullchain_path=<certbot.cli._Default object at 0x7f897d4d89d0>, func=<function run at 0x7f89774ae1b8>, hsts=<certbot.cli._Default object at 0x7f897d554110>, http01_port=<certbot.cli._Default object at 0x7f897d547750>, ifaces=<certbot.cli._Default object at 0x7f897d4d85d0>, init=<certbot.cli._Default object at 0x7f897d4d83d0>, installer=<certbot.cli._Default object at 0x7f897d4d8fd0>, key_path=<certbot.cli._Default object at 0x7f897d4d88d0>, logs_dir=<certbot.cli._Default object at 0x7f897d4d8dd0>, manual=<certbot.cli._Default object at 0x7f897d4dd610>, manual_auth_hook=<certbot.cli._Default object at 0x7f897d4dd850>, manual_cleanup_hook=<certbot.cli._Default object at 0x7f897d4dd990>, manual_public_ip_logging_ok=<certbot.cli._Default object at 0x7f897d4dda90>, must_staple=<certbot.cli._Default object at 0x7f897d547250>, nginx=<certbot.cli._Default object at 0x7f897d4dd410>, no_bootstrap=<certbot.cli._Default object at 0x7f897d52f8d0>, no_self_upgrade=<certbot.cli._Default object at 0x7f897d52fa90>, no_verify_ssl=<certbot.cli._Default object at 0x7f897d547a90>, noninteractive_mode=<certbot.cli._Default object at 0x7f897d53c850>, num=<certbot.cli._Default object at 0x7f897d554e90>, os_packages_only=<certbot.cli._Default object at 0x7f897d52fc10>, post_hook=<certbot.cli._Default object at 0x7f897d554a10>, pre_hook=<certbot.cli._Default object at 0x7f897d554910>, pref_challs=<certbot.cli._Default object at 0x7f897d554810>, prepare=<certbot.cli._Default object at 0x7f897d4d84d0>, quiet=<certbot.cli._Default object at 0x7f897d52f750>, reason=<certbot.cli._Default object at 0x7f897d4d81d0>, redirect=<certbot.cli._Default object at 0x7f897d5470d0>, register_unsafely_without_email=<certbot.cli._Default object at 0x7f897d53c090>, reinstall=<certbot.cli._Default object at 0x7f897d5348d0>, renew_by_default=<certbot.cli._Default object at 0x7f897d534550>, renew_hook=<certbot.cli._Default object at 0x7f897d554b10>, renew_with_new_domains=<certbot.cli._Default object at 0x7f897d5343d0>, rsa_key_size=<certbot.cli._Default object at 0x7f897d5473d0>, server=<certbot.cli._Default object at 0x7f897d4d8ed0>, staging=<certbot.cli._Default object at 0x7f897d52f150>, standalone=<certbot.cli._Default object at 0x7f897d4dd510>, standalone_supported_challenges=<certbot.cli._Default object at 0x7f897d4ddbd0>, staple=<certbot.cli._Default object at 0x7f897d554510>, strict_permissions=<certbot.cli._Default object at 0x7f897d554710>, text_mode=<certbot.cli._Default object at 0x7f897d53c9d0>, tls_sni_01_port=<certbot.cli._Default object at 0x7f897d547910>, tos=<certbot.cli._Default object at 0x7f897d521cd0>, uir=<certbot.cli._Default object at 0x7f897d554310>, update_registration=<certbot.cli._Default object at 0x7f897d534ed0>, user_agent=<certbot.cli._Default object at 0x7f897d554f90>, validate_hooks=<certbot.cli._Default object at 0x7f897d554c10>, verb='run', verbose_count=<certbot.cli._Default object at 0x7f897d53cb50>, webroot=<certbot.cli._Default object at 0x7f897d4dd710>, webroot_map=<certbot.cli._Default object at 0x7f897d4dddd0>, webroot_path=<certbot.cli._Default object at 0x7f897d4dd810>, work_dir=<certbot.cli._Default object at 0x7f897d4d8cd0>)
2017-06-06 12:19:26,588:DEBUG:certbot.log:Root logging level set at 20
2017-06-06 12:19:26,589:INFO:certbot.log:Saving debug log to /var/log/letsencrypt/letsencrypt.log
2017-06-06 12:19:26,590:DEBUG:certbot.plugins.selection:Requested authenticator None and installer None
2017-06-06 12:19:26,590:DEBUG:certbot.plugins.selection:No candidate plugin
2017-06-06 12:19:26,590:DEBUG:certbot.plugins.selection:Selected authenticator None and installer None ```

## Here is the relevant nginx server block or Apache virtualhost for the domain I am configuring:
I dont think this is relevant for this ticket. The domain is http://hoeveelmensengaveneeneuroomtezienhoeveelmenseneeneurogaven.nl.



Discussion:
I'm not sure why the error message is "is too long", but I think the issue with your invocation is the "http://".

What happens if you run:
`sudo certbot -d hoeveelmensengaveneeneuroomtezienhoeveelmenseneeneurogaven.nl`?

Resolving patch:
diff --git a/certbot/util.py b/certbot/util.py
--- a/certbot/util.py
+++ b/certbot/util.py
@@ -568,6 +568,17 @@ def enforce_domain_sanity(domain):
     # Remove trailing dot
     domain = domain[:-1] if domain.endswith(u'.') else domain
 
+    # Separately check for odd "domains" like "http://example.com" to fail
+    # fast and provide a clear error message
+    for scheme in ["http", "https"]:  # Other schemes seem unlikely
+        if domain.startswith("{0}://".format(scheme)):
+            raise errors.ConfigurationError(
+                "Requested name {0} appears to be a URL, not a FQDN. "
+                "Try again without the leading \"{1}://\".".format(
+                    domain, scheme
+                )
+            )
+
     # Explain separately that IP addresses aren't allowed (apart from not
     # being FQDNs) because hope springs eternal concerning this point
     try:


Test patch:
diff --git a/certbot/tests/util_test.py b/certbot/tests/util_test.py
--- a/certbot/tests/util_test.py
+++ b/certbot/tests/util_test.py
@@ -420,6 +420,13 @@ def test_one_label(self):
     def test_valid_domain(self):
         self.assertEqual(self._call(u"example.com"), u"example.com")
 
+    def test_input_with_scheme(self):
+        self.assertRaises(errors.ConfigurationError, self._call, u"http://example.com")
+        self.assertRaises(errors.ConfigurationError, self._call, u"https://example.com")
+
+    def test_valid_input_with_scheme_name(self):
+        self.assertEqual(self._call(u"http.example.com"), u"http.example.com")
+
 
 class EnforceDomainSanityTest(unittest.TestCase):
     """Test enforce_domain_sanity."""