fix variable ssl

This commit is contained in:
VirtuBox
2019-03-22 06:22:00 +01:00
parent a675a50aef
commit dbda71c3ef

View File

@@ -1205,62 +1205,62 @@ def setupLetsEncrypt(self, wo_domain_name):
Log.warn(self, "Please wait while we fetch the new HTTPS certificate" Log.warn(self, "Please wait while we fetch the new HTTPS certificate"
" for your site.\nIt may take a few minutes" " for your site.\nIt may take a few minutes"
" depending on the network.") " depending on the network.")
sslissue = WOShellExec.cmd_exec(self, "/etc/letsencrypt/acme.sh " ssl = WOShellExec.cmd_exec(self, "/etc/letsencrypt/acme.sh "
"--config-home " "--config-home "
"'/etc/letsencrypt/config' " "'/etc/letsencrypt/config' "
"--issue " "--issue "
"-d {0} -d www.{0} -w /var/www/html " "-d {0} -d www.{0} -w /var/www/html "
"-k ec-384" "-k ec-384"
.format(wo_domain_name)) .format(wo_domain_name))
if sslissue:
if ssl:
try:
Log.debug(self, "Cert deployment for domain: {0}" Log.debug(self, "Cert deployment for domain: {0}"
.format(wo_domain_name)) .format(wo_domain_name))
ssl = WOShellExec.cmd_exec(self, "mkdir -p {0}/{1} && " sslsetup = WOShellExec.cmd_exec(self, "mkdir -p {0}/{1} && "
"/etc/letsencrypt/acme.sh " "/etc/letsencrypt/acme.sh "
"--config-home " "--config-home "
"'/etc/letsencrypt/config' " "'/etc/letsencrypt/config' "
"--install-cert -d {1} --ecc " "--install-cert -d {1} --ecc "
"--cert-file {0}/{1}/cert.pem " "--cert-file {0}/{1}/cert.pem "
"--key-file {0}/{1}/key.pem " "--key-file {0}/{1}/key.pem "
"--fullchain-file " "--fullchain-file "
"{0}/{1}/fullchain.pem " "{0}/{1}/fullchain.pem "
"--reloadcmd " "--reloadcmd "
"\"service nginx restart\" " "\"service nginx restart\" "
.format(WOVariables.wo_ssl_live, .format(WOVariables.wo_ssl_live,
wo_domain_name)) wo_domain_name))
if ssl: Log.info(
self, "Adding /var/www/{0}/conf/nginx/ssl.conf"
.format(wo_domain_name))
try: sslconf = open("/var/www/{0}/conf/nginx/ssl.conf"
Log.info( .format(wo_domain_name),
self, "Adding /var/www/{0}/conf/nginx/ssl.conf" encoding='utf-8', mode='w')
.format(wo_domain_name)) sslconf.write("listen 443 ssl http2;\n"
"listen [::]:443 ssl http2;\n"
"ssl on;\n"
"ssl_certificate {0}/{1}/fullchain.pem;\n"
"ssl_certificate_key {0}/{1}/key.pem;\n"
.format(WOVariables.wo_ssl_live, wo_domain_name))
sslconf.close()
updateSiteInfo(self, wo_domain_name, ssl=True)
sslconf = open("/var/www/{0}/conf/nginx/ssl.conf" WOGit.add(self, ["/etc/letsencrypt"],
.format(wo_domain_name), msg="Adding letsencrypt folder")
encoding='utf-8', mode='w')
sslconf.write("listen 443 ssl http2;\n"
"listen [::]:443 ssl http2;\n"
"ssl on;\n"
"ssl_certificate {0}/{1}/fullchain.pem;\n"
"ssl_certificate_key {0}/{1}/key.pem;\n"
.format(WOVariables.wo_ssl_live, wo_domain_name))
sslconf.close()
updateSiteInfo(self, wo_domain_name, ssl=True)
WOGit.add(self, ["/etc/letsencrypt"], except IOError as e:
msg="Adding letsencrypt folder") Log.debug(self, str(e))
Log.debug(self, "Error occured while generating "
except IOError as e: "ssl.conf")
Log.debug(self, str(e)) else:
Log.debug(self, "Error occured while generating " Log.error(self, "Unable to install certificate", False)
"ssl.conf") Log.error(self, "Please make sure that your site is pointed to \n"
else: "same server on which "
Log.error(self, "Unable to install certificate", False) "you are running Let\'s Encrypt Client "
Log.error(self, "Please make sure that your site is pointed to \n" "\n to allow it to verify the site automatically.")
"same server on which "
"you are running Let\'s Encrypt Client "
"\n to allow it to verify the site automatically.")
# setup letsencrypt for a subdomain # setup letsencrypt for a subdomain
@@ -1276,63 +1276,62 @@ def setupLetsEncryptSubdomain(self, wo_domain_name):
Log.info(self, "Please wait while we fetch the new HTTPS certificate" Log.info(self, "Please wait while we fetch the new HTTPS certificate"
" for your site.\nIt may take a few minutes" " for your site.\nIt may take a few minutes"
" depending on the network.") " depending on the network.")
sslissue = WOShellExec.cmd_exec(self, "/etc/letsencrypt/acme.sh " ssl = WOShellExec.cmd_exec(self, "/etc/letsencrypt/acme.sh "
"--config-home " "--config-home "
"'/etc/letsencrypt/config' " "'/etc/letsencrypt/config' "
"--issue " "--issue "
"-d {0} -w /var/www/html " "-d {0} -w /var/www/html "
"-k ec-384" "-k ec-384"
.format(wo_domain_name)) .format(wo_domain_name))
if sslissue: if ssl:
try:
Log.debug(self, "Cert deployment for domain: {0}" Log.debug(self, "Cert deployment for domain: {0}"
.format(wo_domain_name)) .format(wo_domain_name))
ssl = WOShellExec.cmd_exec(self, "mkdir -p {0}/{1} && " sslsetup = WOShellExec.cmd_exec(self, "mkdir -p {0}/{1} && "
"/etc/letsencrypt/acme.sh " "/etc/letsencrypt/acme.sh "
"--config-home " "--config-home "
"'/etc/letsencrypt/config' " "'/etc/letsencrypt/config' "
"--install-cert -d {1} --ecc " "--install-cert -d {1} --ecc "
"--cert-file {0}/{1}/cert.pem " "--cert-file {0}/{1}/cert.pem "
"--key-file {0}/{1}/key.pem " "--key-file {0}/{1}/key.pem "
"--fullchain-file " "--fullchain-file "
"{0}/{1}/fullchain.pem " "{0}/{1}/fullchain.pem "
"--reloadcmd " "--reloadcmd "
"\"service nginx restart\" " "\"service nginx restart\" "
.format(WOVariables.wo_ssl_live, .format(WOVariables.wo_ssl_live,
wo_domain_name)) wo_domain_name))
if ssl: Log.info(
self, "Adding /var/www/{0}/conf/nginx/ssl.conf"
.format(wo_domain_name))
try: sslconf = open("/var/www/{0}/conf/nginx/ssl.conf"
Log.info( .format(wo_domain_name),
self, "Adding /var/www/{0}/conf/nginx/ssl.conf" encoding='utf-8', mode='w')
.format(wo_domain_name)) sslconf.write("listen 443 ssl http2;\n"
"listen [::]:443 ssl http2;\n"
"ssl on;\n"
"ssl_certificate {0}/{1}/fullchain.pem;\n"
"ssl_certificate_key {0}/{1}/key.pem;\n"
.format(WOVariables.wo_ssl_live, wo_domain_name))
sslconf.close()
updateSiteInfo(self, wo_domain_name, ssl=True)
sslconf = open("/var/www/{0}/conf/nginx/ssl.conf" WOGit.add(self, ["/etc/letsencrypt"],
.format(wo_domain_name), msg="Adding letsencrypt folder")
encoding='utf-8', mode='w')
sslconf.write("listen 443 ssl http2;\n"
"listen [::]:443 ssl http2;\n"
"ssl on;\n"
"ssl_certificate {0}/{1}/fullchain.pem;\n"
"ssl_certificate_key {0}/{1}/key.pem;\n"
.format(WOVariables.wo_ssl_live, wo_domain_name))
sslconf.close()
updateSiteInfo(self, wo_domain_name, ssl=True)
WOGit.add(self, ["/etc/letsencrypt"], except IOError as e:
msg="Adding letsencrypt folder") Log.debug(self, str(e))
Log.debug(self, "Error occured while generating "
except IOError as e: "ssl.conf")
Log.debug(self, str(e)) else:
Log.debug(self, "Error occured while generating " Log.error(self, "Unable to create ssl.conf", False)
"ssl.conf") Log.error(self, "Please make sure that your site is pointed to \n"
else: "same server on which "
Log.error(self, "Unable to create ssl.conf", False) "you are running Let\'s Encrypt Client "
Log.error(self, "Please make sure that your site is pointed to \n" "\n to allow it to verify the site automatically.")
"same server on which "
"you are running Let\'s Encrypt Client "
"\n to allow it to verify the site automatically.")
# letsencrypt cert renewal # letsencrypt cert renewal
@@ -1541,4 +1540,4 @@ def archivedCertificateHandle(self, domain):
'/var/www/{0}/conf/nginx/ssl.conf.bak' '/var/www/{0}/conf/nginx/ssl.conf.bak'
.format(domain)) .format(domain))
return ssl return ssl