Improve acme and check dns before issuing cert

This commit is contained in:
VirtuBox
2019-09-24 01:59:49 +02:00
parent dd5fe9f416
commit 1d8164e583
4 changed files with 49 additions and 27 deletions

View File

@@ -40,24 +40,11 @@ class WOAcme:
self, "Please make sure your properly "
"set your DNS API credentials for acme.sh")
else:
server_ip = requests.get('http://v4.wordops.eu/').text
for domain in acme_domains:
domain_ip = requests.get('http://v4.wordops.eu/dns/{0}/'
.format(domain)).text
if(not domain_ip == server_ip):
Log.warn(
self, "{0} is not pointing to your server IP"
.format(domain))
Log.error(
self, "You have to add the "
"proper DNS record", False)
break
else:
Log.error(
self, "Your domain is properly configured "
"but acme.sh was unable to issue certificate.\n"
"You can find more informations in "
"/var/log/wo/wordops.log", False)
Log.error(
self, "Your domain is properly configured "
"but acme.sh was unable to issue certificate.\n"
"You can find more informations in "
"/var/log/wo/wordops.log", False)
return False
else:
Log.valide(self, "Issuing SSL cert with acme.sh")
@@ -124,3 +111,22 @@ class WOAcme:
Log.debug(self, str(e))
Log.debug(self, "Error occured while generating "
"ssl.conf")
def check_dns(self, acme_domains):
"""Check if a list of domains point to the server IP"""
server_ip = requests.get('http://v4.wordops.eu/').text
for domain in acme_domains:
domain_ip = requests.get('http://v4.wordops.eu/dns/{0}/'
.format(domain)).text
if(not domain_ip == server_ip):
Log.warn(
self, "{0} is not pointing to your server IP"
.format(domain))
Log.error(
self, "You have to add the "
"proper DNS record", False)
return False
break
else:
Log.debug(self, "DNS record are properly set")
return True