修复获取证书时无法找到root domain

This commit is contained in:
jingrow 2025-04-19 22:37:20 +08:00
parent 261e63208f
commit 2196c19ac7

View File

@ -13,7 +13,6 @@ from jcloud.api.site import check_dns_cname_a
from jcloud.overrides import get_permission_query_conditions_for_pagetype
from jcloud.runner import Ansible
from jcloud.utils import get_current_team, log_error
from tldextract import extract
class TLSCertificate(Document):
@ -332,6 +331,9 @@ class LetsEncrypt:
def _obtain(self):
"""根据域名类型选择验证方式"""
if not os.path.exists(self.directory):
os.mkdir(self.directory)
if self.wildcard:
# 通配符域名需要DNS验证和Root Domain记录
self._obtain_wildcard()
@ -345,12 +347,9 @@ class LetsEncrypt:
- 'AWS Route 53' => AWS_ACCESS_KEY_ID / SECRET
- 'DNSPod' => 生成临时 ini 文件, -a dns-dnspod
"""
# 如果是通配符域名,就去掉"*."前缀
# 对于通配符证书,直接使用域名而不提取根域名
domain_to_check = self.domain[2:] if self.domain.startswith("*.") else self.domain
# 使用tldextract提取根域名
extracted = extract(domain_to_check)
root_domain = f"{extracted.domain}.{extracted.suffix}"
domain_pg = jingrow.get_pg("Root Domain", root_domain)
domain_pg = jingrow.get_pg("Root Domain", domain_to_check)
provider = domain_pg.dns_provider
if provider == "AWS Route 53":