diff --git a/wo/cli/plugins/site.py b/wo/cli/plugins/site.py index 5b03141..6099ce2 100644 --- a/wo/cli/plugins/site.py +++ b/wo/cli/plugins/site.py @@ -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: diff --git a/wo/cli/plugins/site_functions.py b/wo/cli/plugins/site_functions.py index 91eff6e..f2abb29 100644 --- a/wo/cli/plugins/site_functions.py +++ b/wo/cli/plugins/site_functions.py @@ -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