Fix Windows webroot crash when multiple domains have the same webroot (#9108)

* Certificate issuing on Window while having web.confing and more then one domain in request

* add a test

* update changelog

Co-authored-by: Serghei Trufkin <Serghei.Trufkin@Technosoft.md>
This commit is contained in:
alexzorin
2021-11-22 19:00:55 +01:00
committed by GitHub
co-authored by Serghei Trufkin
parent d2578e05e7
commit 6766786049
3 changed files with 19 additions and 1 deletions
+2
View File
@@ -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.
+1 -1
View File
@@ -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:
+16
View File
@@ -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 = []