fix letsencrypt

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

View File

@@ -1229,44 +1229,43 @@ def setupLetsEncrypt(self, wo_domain_name):
"\"service nginx restart\" " "\"service nginx restart\" "
.format(WOVariables.wo_ssl_live, .format(WOVariables.wo_ssl_live,
wo_domain_name)) wo_domain_name))
if ssl: if ssl:
try: try:
Log.info( Log.info(
self, "Adding /var/www/{0}/conf/nginx/ssl.conf" self, "Adding /var/www/{0}/conf/nginx/ssl.conf"
.format(wo_domain_name)) .format(wo_domain_name))
sslconf = open("/var/www/{0}/conf/nginx/ssl.conf" sslconf = open("/var/www/{0}/conf/nginx/ssl.conf"
.format(wo_domain_name), .format(wo_domain_name),
encoding='utf-8', mode='w') encoding='utf-8', mode='w')
sslconf.write("listen 443 ssl http2;\n" sslconf.write("listen 443 ssl http2;\n"
"listen [::]:443 ssl http2;\n" "listen [::]:443 ssl http2;\n"
"ssl on;\n" "ssl on;\n"
"ssl_certificate {0}/{1}/fullchain.pem;\n" "ssl_certificate {0}/{1}/fullchain.pem;\n"
"ssl_certificate_key {0}/{1}/key.pem;\n" "ssl_certificate_key {0}/{1}/key.pem;\n"
.format(WOVariables.wo_ssl_live, wo_domain_name)) .format(WOVariables.wo_ssl_live, wo_domain_name))
sslconf.close() sslconf.close()
updateSiteInfo(self, wo_domain_name, ssl=True) updateSiteInfo(self, wo_domain_name, ssl=True)
WOGit.add(self, ["/etc/letsencrypt"], WOGit.add(self, ["/etc/letsencrypt"],
msg="Adding letsencrypt folder") msg="Adding letsencrypt folder")
except IOError as e: except IOError as e:
Log.debug(self, str(e)) Log.debug(self, str(e))
Log.debug(self, "Error occured while generating " Log.debug(self, "Error occured while generating "
"ssl.conf") "ssl.conf")
else: else:
Log.error(self, "Unable to install certificate", False) Log.error(self, "Unable to install certificate", False)
Log.error(self, "Please make sure that your site is pointed to \n" Log.error(self, "Please make sure that your site is pointed to \n"
"same server on which " "same server on which "
"you are running Let\'s Encrypt Client " "you are running Let\'s Encrypt Client "
"\n to allow it to verify the site automatically.") "\n to allow it to verify the site automatically.")
# setup letsencrypt for a subdomain # setup letsencrypt for a subdomain
def setupLetsEncryptSubdomain(self, wo_domain_name): def setupLetsEncryptSubdomain(self, wo_domain_name):
wo_wp_email = WOVariables.wo_email
if os.path.isfile("{0}/{1}_ecc/{1}.conf" if os.path.isfile("{0}/{1}_ecc/{1}.conf"
.format(WOVariables.wo_ssl_archive, wo_domain_name)): .format(WOVariables.wo_ssl_archive, wo_domain_name)):
@@ -1274,7 +1273,7 @@ def setupLetsEncryptSubdomain(self, wo_domain_name):
.format(wo_domain_name)) .format(wo_domain_name))
ssl = archivedCertificateHandle(self, wo_domain_name) ssl = archivedCertificateHandle(self, wo_domain_name)
else: else:
Log.warn(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 " sslissue = WOShellExec.cmd_exec(self, "/etc/letsencrypt/acme.sh "
@@ -1301,38 +1300,39 @@ def setupLetsEncryptSubdomain(self, wo_domain_name):
"\"service nginx restart\" " "\"service nginx restart\" "
.format(WOVariables.wo_ssl_live, .format(WOVariables.wo_ssl_live,
wo_domain_name)) wo_domain_name))
if ssl:
try: if ssl:
Log.info(
self, "Adding /var/www/{0}/conf/nginx/ssl.conf"
.format(wo_domain_name))
sslconf = open("/var/www/{0}/conf/nginx/ssl.conf" try:
.format(wo_domain_name), Log.info(
encoding='utf-8', mode='w') self, "Adding /var/www/{0}/conf/nginx/ssl.conf"
sslconf.write("listen 443 ssl http2;\n" .format(wo_domain_name))
"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"], sslconf = open("/var/www/{0}/conf/nginx/ssl.conf"
msg="Adding letsencrypt folder") .format(wo_domain_name),
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)
except IOError as e: WOGit.add(self, ["/etc/letsencrypt"],
Log.debug(self, str(e)) msg="Adding letsencrypt folder")
Log.debug(self, "Error occured while generating "
"ssl.conf") except IOError as e:
else: Log.debug(self, str(e))
Log.error(self, "Unable to install certificate", False) Log.debug(self, "Error occured while generating "
Log.error(self, "Please make sure that your site is pointed to \n" "ssl.conf")
"same server on which " else:
"you are running Let\'s Encrypt Client " Log.error(self, "Unable to create ssl.conf", False)
"\n to allow it to verify the site automatically.") Log.error(self, "Please make sure that your site is pointed to \n"
"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