Fix sslutils

This commit is contained in:
VirtuBox
2019-09-03 19:02:00 +02:00
parent f7be08eaac
commit 6a7d1fc356
3 changed files with 52 additions and 76 deletions

View File

@@ -1,6 +1,7 @@
import os
from wo.core.shellexec import WOShellExec
from wo.core.logging import Log
from wo.core.shellexec import WOShellExec
class SSL:
@@ -18,15 +19,12 @@ class SSL:
"`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 \""
"`/usr/bin/openssl "
"x509 -in "
"/etc/letsencrypt/live/"
"{0}/cert.pem"
" -text -noout|grep "
"\"Not After\"|"
"cut -c 25-`\" "
"+%s".format(domain))
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):
@@ -45,13 +43,9 @@ class SSL:
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))
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