mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-08 06:16:08 +01:00
bug fix: SSL Renewer
This commit is contained in:
@@ -138,9 +138,9 @@ class installUtilities:
|
||||
try:
|
||||
|
||||
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||
command = "sudo systemctl restart lsws"
|
||||
command = "systemctl restart lsws"
|
||||
else:
|
||||
command = "sudo /usr/local/lsws/bin/lswsctrl restart"
|
||||
command = "/usr/local/lsws/bin/lswsctrl restart"
|
||||
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
|
||||
@@ -37,6 +37,14 @@ class Renew:
|
||||
if int(diff.days) >= 15:
|
||||
logging.writeToFile(
|
||||
'SSL exists for %s and is not ready to renew, skipping..' % (website.domain))
|
||||
elif x509.get_issuer().get_components()[1][1] == 'Denial':
|
||||
logging.writeToFile(
|
||||
'SSL exists for %s and ready to renew..' % (website.domain))
|
||||
logging.writeToFile(
|
||||
'Renewing SSL for %s..' % (website.domain))
|
||||
|
||||
virtualHostUtilities.issueSSL(website.domain, '/home/%s/public_html' % (website.domain),
|
||||
website.adminEmail)
|
||||
else:
|
||||
logging.writeToFile(
|
||||
'SSL exists for %s and ready to renew..' % (website.domain))
|
||||
@@ -69,6 +77,14 @@ class Renew:
|
||||
if int(diff.days) >= 15:
|
||||
logging.writeToFile(
|
||||
'SSL exists for %s and is not ready to renew, skipping..' % (website.domain))
|
||||
elif x509.get_issuer().get_components()[1][1] == 'Denial':
|
||||
logging.writeToFile(
|
||||
'SSL exists for %s and ready to renew..' % (website.domain))
|
||||
logging.writeToFile(
|
||||
'Renewing SSL for %s..' % (website.domain))
|
||||
|
||||
virtualHostUtilities.issueSSL(website.domain, website.path,
|
||||
website.master.adminEmail)
|
||||
else:
|
||||
logging.writeToFile(
|
||||
'SSL exists for %s and ready to renew..' % (website.domain))
|
||||
|
||||
@@ -348,7 +348,19 @@ def issueSSLForDomain(domain, adminEmail, sslpath, aliasDomain = None):
|
||||
else:
|
||||
return [0, "210 Failed to install SSL for domain. [issueSSLForDomain]"]
|
||||
else:
|
||||
return [0, "283 Failed to obtain SSL for domain. [issueSSLForDomain]"]
|
||||
|
||||
pathToStoreSSLPrivKey = "/etc/letsencrypt/live/%s/privkey.pem" % (domain)
|
||||
pathToStoreSSLFullChain = "/etc/letsencrypt/live/%s/fullchain.pem" % (domain)
|
||||
|
||||
command = 'openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout ' + pathToStoreSSLPrivKey + ' -out ' + pathToStoreSSLFullChain
|
||||
cmd = shlex.split(command)
|
||||
subprocess.call(cmd)
|
||||
|
||||
if sslUtilities.installSSLForDomain(domain) == 1:
|
||||
logging.CyberCPLogFileWriter.writeToFile("Self signed SSL issued for " + domain + ".")
|
||||
return [1, "None"]
|
||||
else:
|
||||
return [0, "210 Failed to install SSL for domain. [issueSSLForDomain]"]
|
||||
|
||||
except BaseException,msg:
|
||||
return [0, "347 "+ str(msg)+ " [issueSSLForDomain]"]
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import OpenSSL
|
||||
from datetime import datetime
|
||||
filePath = '/etc/letsencrypt/live/%s/fullchain.pem' % ('hello.com')
|
||||
x509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM,
|
||||
open(filePath, 'r').read())
|
||||
expireData = x509.get_notAfter().decode('ascii')
|
||||
finalDate = datetime.strptime(expireData, '%Y%m%d%H%M%SZ')
|
||||
print x509.get_issuer().get_components()[1][1]
|
||||
@@ -79,7 +79,7 @@
|
||||
{% if viewSSL == 1 %}
|
||||
<div style="margin-top: 2%" class="alert alert-success">
|
||||
<div class="alert-content">
|
||||
<h4 class="alert-title">Certificate from {{ authority }}</h4>
|
||||
<h4 class="alert-title">{{ authority }}</h4>
|
||||
<p>Your SSL will expire in {{ days }} days.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
{% if viewSSL == 1 %}
|
||||
<div style="margin-top: 2%" class="alert alert-success">
|
||||
<div class="alert-content">
|
||||
<h4 class="alert-title">Certificate from {{ authority }}</h4>
|
||||
<h4 class="alert-title">{{ authority }}</h4>
|
||||
<p>Your SSL will expire in {{ days }} days.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -759,6 +759,12 @@ class WebsiteManager:
|
||||
Data['viewSSL'] = 1
|
||||
Data['days'] = str(diff.days)
|
||||
Data['authority'] = x509.get_issuer().get_components()[1][1]
|
||||
|
||||
if Data['authority'] == 'Denial':
|
||||
Data['authority'] = '%s has SELF-SIGNED SSL.' % (self.domain)
|
||||
else:
|
||||
Data['authority'] = '%s has SSL from %s.' % (self.domain, Data['authority'])
|
||||
|
||||
except BaseException, msg:
|
||||
Data['viewSSL'] = 0
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
@@ -861,6 +867,12 @@ class WebsiteManager:
|
||||
Data['viewSSL'] = 1
|
||||
Data['days'] = str(diff.days)
|
||||
Data['authority'] = x509.get_issuer().get_components()[1][1]
|
||||
|
||||
if Data['authority'] == 'Denial':
|
||||
Data['authority'] = '%s has SELF-SIGNED SSL.' % (self.domain)
|
||||
else:
|
||||
Data['authority'] = '%s has SSL from %s.' % (self.domain, Data['authority'])
|
||||
|
||||
except BaseException, msg:
|
||||
Data['viewSSL'] = 0
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
|
||||
Reference in New Issue
Block a user