Refactor function
This commit is contained in:
@@ -761,7 +761,8 @@ class WOSiteCreateController(CementBaseController):
|
|||||||
(not pargs.letsencrypt == 'wildcard')):
|
(not pargs.letsencrypt == 'wildcard')):
|
||||||
wo_subdomain = True
|
wo_subdomain = True
|
||||||
# check if a wildcard cert for the root domain exist
|
# 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
|
# copy the cert from the root domain
|
||||||
copyWildcardCert(self, wo_domain, wo_root_domain)
|
copyWildcardCert(self, wo_domain, wo_root_domain)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -1479,19 +1479,18 @@ def checkWildcardExist(self, wo_domain_name):
|
|||||||
# define new csv dialect
|
# define new csv dialect
|
||||||
csv.register_dialect('acmeconf', delimiter='|')
|
csv.register_dialect('acmeconf', delimiter='|')
|
||||||
# open file
|
# open file
|
||||||
with open('/var/lib/wo/cert.csv', 'rt') as wo_cert:
|
certfile = open('/var/lib/wo/cert.csv', 'rt')
|
||||||
reader = csv.reader(wo_cert, 'acmeconf')
|
reader = csv.reader(certfile, 'acmeconf')
|
||||||
wo_wildcard_domain = ("*.{0}".format(wo_domain_name))
|
wo_wildcard_domain = ("*.{0}".format(wo_domain_name))
|
||||||
try:
|
for row in reader:
|
||||||
for row in reader:
|
if wo_wildcard_domain in row[2]:
|
||||||
if wo_wildcard_domain in row[2]:
|
isWildcard = True
|
||||||
return True
|
break
|
||||||
break
|
else:
|
||||||
else:
|
isWildcard = False
|
||||||
return False
|
certfile.close()
|
||||||
except csv.Error as e:
|
|
||||||
Log.debug(self, "{0}".format(e))
|
return isWildcard
|
||||||
Log.error(self, "Failed to read cert list")
|
|
||||||
|
|
||||||
|
|
||||||
# copy wildcard certificate to a subdomain
|
# copy wildcard certificate to a subdomain
|
||||||
|
|||||||
Reference in New Issue
Block a user