Update cert_api.py

pull/267/head
midoks 3 years ago
parent a5861ce04e
commit 0cb320cb23
  1. 27
      class/core/cert_api.py

@ -1383,7 +1383,7 @@ fullchain.pem 粘贴到证书输入框
return siteName return siteName
def renewCertTo(self, domains, auth_type, auth_to, index=None): def renewCertTo(self, domains, auth_type, auth_to, index=None):
siteName = None site_name = None
cert = {} cert = {}
import site_api import site_api
@ -1391,21 +1391,18 @@ fullchain.pem 粘贴到证书输入框
if os.path.exists(auth_to): if os.path.exists(auth_to):
if mw.M('sites').where('path=?', auth_to).count() == 1: if mw.M('sites').where('path=?', auth_to).count() == 1:
site_id = m.M('sites').where('path=?', auth_to).getField('id') site_id = m.M('sites').where('path=?', auth_to).getField('id')
siteName = m.M('sites').where( site_name = m.M('sites').where(
'path=?', auth_to).getField('name') 'path=?', auth_to).getField('name')
import panelSite rdata = api.getSiteRunPath(site_id)
siteObj = panelSite.panelSite() runPath = rdata['runPath']
args = public.dict_obj()
args.id = site_id
runPath = siteObj.GetRunPath(args)
if runPath and not runPath in ['/']: if runPath and not runPath in ['/']:
path = auth_to + '/' + runPath path = auth_to + '/' + runPath
if os.path.exists(path): if os.path.exists(path):
auth_to = path.replace('//', '/') auth_to = path.replace('//', '/')
else: else:
siteName = self.getSiteNameByDomains(domains) site_name = self.getSiteNameByDomains(domains)
is_rep = api.httpToHttps(site_name) is_rep = api.httpToHttps(site_name)
try: try:
index = self.createOrder( index = self.createOrder(
@ -1423,11 +1420,11 @@ fullchain.pem 粘贴到证书输入框
self.sendCsr(index) self.sendCsr(index)
writeLog("|-正在下载证书..") writeLog("|-正在下载证书..")
cert = self.downloadCert(index) cert = self.downloadCert(index)
self._config['orders'][index]['renew_time'] = int(time.time()) self.__config['orders'][index]['renew_time'] = int(time.time())
# 清理失败重试记录 # 清理失败重试记录
self._config['orders'][index]['retry_count'] = 0 self.__config['orders'][index]['retry_count'] = 0
self._config['orders'][index]['next_retry_time'] = 0 self.__config['orders'][index]['next_retry_time'] = 0
# 保存证书配置 # 保存证书配置
self.saveConfig() self.saveConfig()
@ -1439,12 +1436,12 @@ fullchain.pem 粘贴到证书输入框
if str(e).find('请稍候重试') == -1: # 受其它证书影响和连接CA失败的的不记录重试次数 if str(e).find('请稍候重试') == -1: # 受其它证书影响和连接CA失败的的不记录重试次数
if index: if index:
# 设置下次重试时间 # 设置下次重试时间
self._config['orders'][index][ self.__config['orders'][index][
'next_retry_time'] = int(time.time() + (86400 * 2)) 'next_retry_time'] = int(time.time() + (86400 * 2))
# 记录重试次数 # 记录重试次数
if not 'retry_count' in self._config['orders'][index].keys(): if not 'retry_count' in self.__config['orders'][index].keys():
self._config['orders'][index]['retry_count'] = 1 self.__config['orders'][index]['retry_count'] = 1
self._config['orders'][index]['retry_count'] += 1 self.__config['orders'][index]['retry_count'] += 1
# 保存证书配置 # 保存证书配置
self.saveConfig() self.saveConfig()
msg = str(e).split('>>>>')[0] msg = str(e).split('>>>>')[0]

Loading…
Cancel
Save