Refactor function

This commit is contained in:
VirtuBox
2019-08-30 08:09:27 +02:00
parent ebea1e5e7d
commit 01c1c3909c
2 changed files with 14 additions and 14 deletions

View File

@@ -761,7 +761,8 @@ class WOSiteCreateController(CementBaseController):
(not pargs.letsencrypt == 'wildcard')):
wo_subdomain = True
# check if a wildcard cert for the root domain exist
if checkWildcardExist(self, wo_root_domain):
isWildcard = checkWildcardExist(self, wo_root_domain)
if isWildcard is True:
# copy the cert from the root domain
copyWildcardCert(self, wo_domain, wo_root_domain)
else:

View File

@@ -1479,19 +1479,18 @@ def checkWildcardExist(self, wo_domain_name):
# define new csv dialect
csv.register_dialect('acmeconf', delimiter='|')
# open file
with open('/var/lib/wo/cert.csv', 'rt') as wo_cert:
reader = csv.reader(wo_cert, 'acmeconf')
wo_wildcard_domain = ("*.{0}".format(wo_domain_name))
try:
for row in reader:
if wo_wildcard_domain in row[2]:
return True
break
else:
return False
except csv.Error as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Failed to read cert list")
certfile = open('/var/lib/wo/cert.csv', 'rt')
reader = csv.reader(certfile, 'acmeconf')
wo_wildcard_domain = ("*.{0}".format(wo_domain_name))
for row in reader:
if wo_wildcard_domain in row[2]:
isWildcard = True
break
else:
isWildcard = False
certfile.close()
return isWildcard
# copy wildcard certificate to a subdomain