Skip to content

Commit

Permalink
优化 证书申请域名验证通过后自动加入到证书监控列表
Browse files Browse the repository at this point in the history
  • Loading branch information
mouday committed Aug 30, 2023
1 parent 3aeb889 commit e1a5ac4
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions domain_admin/api/issue_certificate_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
@Date : 2023-07-23
"""
from flask import g, request
from playhouse.shortcuts import model_to_dict
from playhouse.shortcuts import model_to_dict, chunked

from domain_admin.model.domain_model import DomainModel
from domain_admin.model.host_model import HostModel
from domain_admin.model.issue_certificate_model import IssueCertificateModel
from domain_admin.service import issue_certificate_service
from domain_admin.utils import ip_util
from domain_admin.utils import ip_util, domain_util
from domain_admin.utils.acme_util.challenge_type import ChallengeType
from domain_admin.utils.flask_ext.app_exception import AppException

Expand Down Expand Up @@ -47,6 +48,23 @@ def verify_certificate():

issue_certificate_service.renew_certificate(issue_certificate_id)

# 验证成功后,自动添加到证书监控列表
issue_certificate_row = IssueCertificateModel.get_by_id(issue_certificate_id)

lst = [
{
'domain': domain,
'root_domain': domain_util.get_root_domain(domain),
'port': 443,
'alias': '',
'user_id': current_user_id,
'group_id': 0,
} for domain in issue_certificate_row.domains
]

for batch in chunked(lst, 500):
DomainModel.insert_many(batch).on_conflict_ignore().execute()


def get_certificate_challenges():
issue_certificate_id = request.json['issue_certificate_id']
Expand Down

0 comments on commit e1a5ac4

Please sign in to comment.