diff --git a/certbot/CHANGELOG.md b/certbot/CHANGELOG.md index 8df29801d..0a5849d82 100644 --- a/certbot/CHANGELOG.md +++ b/certbot/CHANGELOG.md @@ -20,6 +20,8 @@ Certbot adheres to [Semantic Versioning](https://semver.org/). * Fixed an issue on Windows where the `web.config` created by Certbot would sometimes conflict with preexisting configurations (#9088). +* Fixed an issue on Windows where the `webroot` plugin would crash when multiple domains + had the same webroot. This affected Certbot 1.21.0. More details about these changes can be found on our GitHub repo. diff --git a/certbot/certbot/_internal/plugins/webroot.py b/certbot/certbot/_internal/plugins/webroot.py index 81f46b204..1a4892ac9 100644 --- a/certbot/certbot/_internal/plugins/webroot.py +++ b/certbot/certbot/_internal/plugins/webroot.py @@ -221,7 +221,7 @@ to serve all files under specified web root ({0}).""" if os.path.exists(web_config_path): logger.info("A web.config file has not been created in " "%s because another one already exists.", self.full_roots[name]) - return + continue logger.info("Creating a web.config file in %s to allow IIS " "to serve challenge files.", self.full_roots[name]) with safe_open(web_config_path, mode="w", chmod=0o644) as web_config: diff --git a/certbot/tests/plugins/webroot_test.py b/certbot/tests/plugins/webroot_test.py index 54c51ae1d..d7e961596 100644 --- a/certbot/tests/plugins/webroot_test.py +++ b/certbot/tests/plugins/webroot_test.py @@ -115,6 +115,22 @@ class AuthenticatorTest(unittest.TestCase): from certbot._internal.plugins.webroot import _WEB_CONFIG_SHA256SUMS self.assertTrue(webconfig_hash not in _WEB_CONFIG_SHA256SUMS) + @unittest.skipIf(filesystem.POSIX_MODE, reason='Test specific to Windows') + def test_foreign_webconfig_multiple_domains(self): + # Covers bug https://github.com/certbot/certbot/issues/9091 + achall_2 = achallenges.KeyAuthorizationAnnotatedChallenge( + challb=acme_util.chall_to_challb(challenges.HTTP01(token=b"bingo"), "pending"), + domain="second-thing.com", account_key=KEY) + self.config.webroot_map["second-thing.com"] = self.path + + challenge_path = os.path.join(self.path, ".well-known", "acme-challenge") + filesystem.makedirs(challenge_path) + + webconfig_path = os.path.join(challenge_path, "web.config") + with open(webconfig_path, "w") as file: + file.write("something") + self.auth.perform([self.achall, achall_2]) + @test_util.patch_display_util() def test_webroot_from_list_help_and_cancel(self, mock_get_utility): self.config.webroot_path = []