Repository: certbot/certbot

Issue:
A CSR with an upper-case domain name is refused
## My operating system is (include version):

Any (mine is Ubuntu)

## I installed Certbot with (certbot-auto, OS package manager, pip, etc):

Any, but mine was from pip

## I ran this command and it produced this output:

certbot certonly --csr file.csr -d OCG-SZ1-CMT.example.com
where file.csr has a request for a domain name with upper case letters in it.

Inconsistent domain requests:
From the CSR: OCG-SZ1-CMT.example.com
From command line/config: ocg-sz1-cmt.example.com

## Certbot's behavior differed from what I expected because:

Domain names are supposed to be case insensitive. It should not matter that the name is mixed case in the CSR.


Discussion:

Resolving patch:
diff --git a/certbot/cli.py b/certbot/cli.py
--- a/certbot/cli.py
+++ b/certbot/cli.py
@@ -620,7 +620,9 @@ def handle_csr(self, parsed_args):
                 % parsed_args.csr[0])
 
         parsed_args.actual_csr = (csr, typ)
-        csr_domains, config_domains = set(domains), set(parsed_args.domains)
+
+        csr_domains = set([d.lower() for d in domains])
+        config_domains = set(parsed_args.domains)
         if csr_domains != config_domains:
             raise errors.ConfigurationError(
                 "Inconsistent domain requests:\nFrom the CSR: {0}\nFrom command line/config: {1}"


Test patch:
diff --git a/certbot/tests/crypto_util_test.py b/certbot/tests/crypto_util_test.py
--- a/certbot/tests/crypto_util_test.py
+++ b/certbot/tests/crypto_util_test.py
@@ -163,7 +163,7 @@ def test_der_csr(self):
              util.CSR(file=csrfile,
                       data=data_pem,
                       form="pem"),
-             ["example.com"],),
+             ["Example.com"],),
             self._call(csrfile, data))
 
     def test_pem_csr(self):
@@ -175,7 +175,7 @@ def test_pem_csr(self):
              util.CSR(file=csrfile,
                       data=data,
                       form="pem"),
-             ["example.com"],),
+             ["Example.com"],),
             self._call(csrfile, data))
 
     def test_bad_csr(self):
diff --git a/certbot/tests/testdata/csr.der b/certbot/tests/testdata/csr.der
Binary files a/certbot/tests/testdata/csr.der and b/certbot/tests/testdata/csr.der differ
diff --git a/certbot/tests/testdata/csr.pem b/certbot/tests/testdata/csr.pem
--- a/certbot/tests/testdata/csr.pem
+++ b/certbot/tests/testdata/csr.pem
@@ -1,10 +1,8 @@
 -----BEGIN CERTIFICATE REQUEST-----
-MIIBXTCCAQcCAQAweTELMAkGA1UEBhMCVVMxETAPBgNVBAgMCE1pY2hpZ2FuMRIw
-EAYDVQQHDAlBbm4gQXJib3IxDDAKBgNVBAoMA0VGRjEfMB0GA1UECwwWVW5pdmVy
-c2l0eSBvZiBNaWNoaWdhbjEUMBIGA1UEAwwLZXhhbXBsZS5jb20wXDANBgkqhkiG
-9w0BAQEFAANLADBIAkEArHVztFHtH92ucFJD/N/HW9AsdRsUuHUBBBDlHwNlRd3f
-p580rv2+6QWE30cWgdmJS86ObRz6lUTor4R0T+3C5QIDAQABoCkwJwYJKoZIhvcN
-AQkOMRowGDAWBgNVHREEDzANggtleGFtcGxlLmNvbTANBgkqhkiG9w0BAQsFAANB
-AHJH/O6BtC9aGzEVCMGOZ7z9iIRHWSzr9x/bOzn7hLwsbXPAgO1QxEwL+X+4g20G
-n9XBE1N9W6HCIEut2d8wACg=
+MIIBFTCBwAIBADBbMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEh
+MB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRQwEgYDVQQDDAtFeGFt
+cGxlLmNvbTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQCsdXO0Ue0f3a5wUkP838db
+0Cx1GxS4dQEEEOUfA2VF3d+nnzSu/b7pBYTfRxaB2YlLzo5tHPqVROivhHRP7cLl
+AgMBAAGgADANBgkqhkiG9w0BAQsFAANBAAceUlq4La8qaiK0DeDP3M19BIVzMmz2
+oemG2fOvPiwNCB90ctSWQ6bMpUMV85ShcFi31C5vlntPfztehhq6YuE=
 -----END CERTIFICATE REQUEST-----