mirror of
https://github.com/certbot/certbot.git
synced 2026-08-02 19:42:02 +02:00
Refactored domain flag checks into their own helper function to clear space for future checks
This commit is contained in:
+23
-11
@@ -1152,17 +1152,29 @@ def check_config_sanity(args):
|
|||||||
"""
|
"""
|
||||||
# Domain checks
|
# Domain checks
|
||||||
if args.domains is not None:
|
if args.domains is not None:
|
||||||
# Check if there's a wildcard domain
|
_check_config_domain_sanity(args.domains)
|
||||||
if any(d.startswith("*.") for d in args.domains):
|
|
||||||
raise errors.ConfigurationError("Error: Wildcard domains are not supported")
|
def _check_config_domain_sanity(domains):
|
||||||
# Punycode
|
"""Helper method for check_config_sanity which validates
|
||||||
if any("xn--" in d for d in args.domains):
|
domain flag values and errors out if the requirements are not met.
|
||||||
raise errors.ConfigurationError("Error: Punycode domains are not supported")
|
|
||||||
# FQDN, checks:
|
:param domains: List of domains
|
||||||
# Characters used, domain parts < 63 chars, tld > 3 < 6 chars
|
:type args: `list` of `string`
|
||||||
fqdn = re.compile("^((?!-)[A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{2,6}$")
|
|
||||||
if any(True for d in args.domains if not fqdn.match(d)):
|
"""
|
||||||
raise errors.ConfigurationError("Error: Requested domain is not FQDN")
|
# Check if there's a wildcard domain
|
||||||
|
if any(d.startswith("*.") for d in domains):
|
||||||
|
raise errors.ConfigurationError(
|
||||||
|
"Error: Wildcard domains are not supported")
|
||||||
|
# Punycode
|
||||||
|
if any("xn--" in d for d in domains):
|
||||||
|
raise errors.ConfigurationError(
|
||||||
|
"Error: Punycode domains are not supported")
|
||||||
|
# FQDN, checks:
|
||||||
|
# Characters used, domain parts < 63 chars, tld > 3 < 6 chars
|
||||||
|
fqdn = re.compile("^((?!-)[A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{2,6}$")
|
||||||
|
if any(True for d in domains if not fqdn.match(d)):
|
||||||
|
raise errors.ConfigurationError("Error: Requested domain is not FQDN")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
err_string = main()
|
err_string = main()
|
||||||
|
|||||||
Reference in New Issue
Block a user