Exemple #1
0
    def getexpirationdays(self, domain, returnonerror=False):
        # check if exist
        if not os.path.isfile(
                '/etc/letsencrypt/live/{0}/cert.pem'.format(domain)):
            Log.error(
                self, 'File Not Found: '
                '/etc/letsencrypt/live/{0}/cert.pem'.format(domain), False)
            if returnonerror:
                return -1
            Log.error(
                self, "Check the WordOps log for more details "
                "`tail /var/log/wo/wordops.log` and please try again...")

        current_date = WOShellExec.cmd_exec_stdout(self, "date -d \"now\" +%s")
        expiration_date = WOShellExec.cmd_exec_stdout(
            self, "date -d \""
            "$(openssl x509 -in /etc/letsencrypt/live/"
            "{0}/cert.pem -text -noout | grep \"Not After\" "
            "| cut -c 25-)\" +%s".format(domain))

        days_left = int((int(expiration_date) - int(current_date)) / 86400)
        if (days_left > 0):
            return days_left
        else:
            # return "Certificate Already Expired ! Please Renew soon."
            return -1
Exemple #2
0
 def siteurlhttps(self, domain):
     wo_site_webroot = ('/var/www/{0}'.format(domain))
     WOFileUtils.chdir(self, '{0}/htdocs/'.format(wo_site_webroot))
     if WOShellExec.cmd_exec(
             self, "{0} --allow-root core is-installed".format(
                 WOVar.wo_wpcli_path)):
         wo_siteurl = (WOShellExec.cmd_exec_stdout(
             self, "{0} option get siteurl ".format(WOVar.wo_wpcli_path) +
             "--allow-root --quiet"))
         test_url = re.split(":", wo_siteurl)
         if not (test_url[0] == 'https'):
             Log.wait(self, "Updating site url with https")
             try:
                 WOShellExec.cmd_exec(
                     self, "{0} option update siteurl "
                     "\'https://{1}\' --allow-root".format(
                         WOVar.wo_wpcli_path, domain))
                 WOShellExec.cmd_exec(
                     self, "{0} option update home "
                     "\'https://{1}\' --allow-root".format(
                         WOVar.wo_wpcli_path, domain))
                 WOShellExec.cmd_exec(
                     self, "{0} search-replace \'http://{1}\'"
                     "\'https://{1}\' --skip-columns=guid "
                     "--skip-tables=wp_users".format(
                         WOVar.wo_wpcli_path, domain))
             except Exception as e:
                 Log.debug(self, str(e))
                 Log.failed(self, "Updating site url with https")
             else:
                 Log.valide(self, "Updating site url with https")
Exemple #3
0
 def export_cert(self):
     """Export acme.sh csv certificate list"""
     # check acme.sh is installed
     WOAcme.check_acme(self)
     acme_list = WOShellExec.cmd_exec_stdout(
         self, "{0} ".format(WOAcme.wo_acme_exec) +
         "--list --listraw")
     if acme_list:
         WOFileUtils.textwrite(self, '/var/lib/wo/cert.csv', acme_list)
         WOFileUtils.chmod(self, '/var/lib/wo/cert.csv', 0o600)
     else:
         Log.error(self, "Unable to export certs list")
Exemple #4
0
    def getexpirationdays(self, domain, returnonerror=False):
        # check if exist
        if not os.path.exists(
                '/etc/letsencrypt/live/{0}/cert.pem'.format(domain)):
            Log.debug(self, "cert not found for {0}".format(domain))

            split_domain = domain.split('.')
            root_domain = ('.').join(split_domain[1:])

            Log.debug(self, "trying with {0}".format(root_domain))
            if os.path.exists(
                    '/etc/letsencrypt/live/{0}/cert.pem'.format(root_domain)):
                domain = root_domain
            else:
                Log.error(
                    self, 'File Not Found: '
                    '/etc/letsencrypt/live/{0}/cert.pem'.format(domain), False)
                Log.error(
                    self, "Check the WordOps log for more details "
                    "`tail /var/log/wo/wordops.log` "
                    "and please try again...")
        Log.debug(
            self,
            "Getting expiration of /etc/letsencrypt/live/{0}/cert.pem".format(
                domain))
        current_date = WOShellExec.cmd_exec_stdout(self, "date -d \"now\" +%s")
        expiration_date = WOShellExec.cmd_exec_stdout(
            self, "date -d \"$(openssl x509 -in /etc/letsencrypt/live/"
            "{0}/cert.pem -text -noout | grep \"Not After\" "
            "| cut -c 25-)\" +%s".format(domain))

        days_left = int((int(expiration_date) - int(current_date)) / 86400)
        if (days_left > 0):
            return days_left
        else:
            # return "Certificate Already Expired ! Please Renew soon."
            return -1
Exemple #5
0
    def getExpirationDate(self, domain):
        # check if exist
        if not os.path.isfile(
                '/etc/letsencrypt/live/{0}/cert.pem'.format(domain)):
            Log.error(
                self,
                'File Not Found : /etc/letsencrypt/live/{0}/cert.pem'.format(
                    domain), False)
            Log.error(
                self, "Check the WordOps log for more details "
                "`tail /var/log/wo/wordops.log` and please try again...")

        expiration_date = WOShellExec.cmd_exec_stdout(
            self,
            "date -d \"`openssl x509 -in /etc/letsencrypt/live/{0}/cert.pem"
            " -text -noout|grep \"Not After\"|cut -c 25-`\" ".format(domain))
        return expiration_date
Exemple #6
0
    def getexpirationdate(self, domain):
        # check if exist
        if os.path.islink('/var/www/{0}/conf/nginx/ssl.conf'):
            split_domain = domain.split('.')
            domain = ('.').join(split_domain[1:])
        if not os.path.isfile(
                '/etc/letsencrypt/live/{0}/cert.pem'.format(domain)):
            Log.error(
                self, 'File Not Found: /etc/letsencrypt/'
                'live/{0}/cert.pem'.format(domain), False)
            Log.error(
                self, "Check the WordOps log for more details "
                "`tail /var/log/wo/wordops.log` and please try again...")

        expiration_date = WOShellExec.cmd_exec_stdout(
            self, "date -d \"$(/usr/bin/openssl x509 -in "
            "/etc/letsencrypt/live/{0}/cert.pem -text -noout | grep "
            "\"Not After\" | cut -c 25-)\" ".format(domain))
        return expiration_date