add subdomains support
This commit is contained in:
parent
1867401b35
commit
d680a58068
3 changed files with 18 additions and 5 deletions
|
@ -9,10 +9,12 @@ using [Certbot](https://certbot.eff.org/) DNS-01 challenge validation for domain
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
The scripts use the [untangle](https://untangle.readthedocs.io/en/latest/) library, if not already installed on your system:
|
The scripts use the [untangle](https://untangle.readthedocs.io/en/latest/) and tldextract libraries, if not already installed on your system:
|
||||||
|
|
||||||
```
|
```
|
||||||
pip install untangle
|
pip install untangle
|
||||||
|
|
||||||
|
pip install tldextract
|
||||||
```
|
```
|
||||||
|
|
||||||
Download the [latest release](https://github.com/ethauvin/namesilo-letsencrypt/releases) archive and expand it in the desired directory.
|
Download the [latest release](https://github.com/ethauvin/namesilo-letsencrypt/releases) archive and expand it in the desired directory.
|
||||||
|
@ -44,3 +46,4 @@ certbot certonly --manual --email you@example.com \
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
Please note that NameSilo DNS propagation takes up to **15 minutes**. The scripts will wait **20 minutes** before completing, just to be safe.
|
Please note that NameSilo DNS propagation takes up to **15 minutes**. The scripts will wait **20 minutes** before completing, just to be safe.
|
||||||
|
q
|
||||||
|
|
|
@ -37,6 +37,7 @@ import tempfile
|
||||||
import time
|
import time
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
|
||||||
|
import tldextract
|
||||||
import untangle
|
import untangle
|
||||||
|
|
||||||
from config import apikey, wait
|
from config import apikey, wait
|
||||||
|
@ -52,14 +53,20 @@ def sleep(minutes):
|
||||||
domain = os.environ['CERTBOT_DOMAIN']
|
domain = os.environ['CERTBOT_DOMAIN']
|
||||||
validation = os.environ['CERTBOT_VALIDATION']
|
validation = os.environ['CERTBOT_VALIDATION']
|
||||||
tmpdir = os.path.join(tempfile.gettempdir(), "CERTBOT_"+domain)
|
tmpdir = os.path.join(tempfile.gettempdir(), "CERTBOT_"+domain)
|
||||||
|
rrhost = "_acme-challenge"
|
||||||
|
|
||||||
if "NAMESILO_API" in os.environ:
|
if "NAMESILO_API" in os.environ:
|
||||||
apikey = os.environ['NAMESILO_API']
|
apikey = os.environ['NAMESILO_API']
|
||||||
|
|
||||||
|
|
||||||
|
tld = tldextract.extract(domain)
|
||||||
|
nsdomain = tld.domain+"."+tld.suffix
|
||||||
|
if tld.subdomain:
|
||||||
|
rrhost += "."+tld.subdomain
|
||||||
|
|
||||||
url = "https://www.namesilo.com/api/dnsAddRecord?\
|
url = "https://www.namesilo.com/api/dnsAddRecord?\
|
||||||
version=1&type=xml&key="+apikey+"&domain="+domain+"&rrtype=TXT\
|
version=1&type=xml&key="+apikey+"&domain="+nsdomain+"&rrtype=TXT\
|
||||||
&rrhost=_acme-challenge&rrvalue="+validation+"&rrttl=3600"
|
&rrhost="+rrhost+"&rrvalue="+validation+"&rrttl=3600"
|
||||||
|
|
||||||
req = urllib.request.Request(
|
req = urllib.request.Request(
|
||||||
url,
|
url,
|
||||||
|
|
|
@ -36,6 +36,7 @@ import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
|
||||||
|
import tldextract
|
||||||
import untangle
|
import untangle
|
||||||
|
|
||||||
from config import apikey
|
from config import apikey
|
||||||
|
@ -47,9 +48,11 @@ tmpdir = os.path.join(tempfile.gettempdir(), "CERTBOT_"+domain)
|
||||||
if "NAMESILO_API" in os.environ:
|
if "NAMESILO_API" in os.environ:
|
||||||
apikey = os.environ['NAMESILO_API']
|
apikey = os.environ['NAMESILO_API']
|
||||||
|
|
||||||
url = "https://www.namesilo.com/api/dnsDeleteRecord\
|
tld = tldextract.extract(domain)
|
||||||
?version=1&type=xml&key="+apikey+"&domain="+domain+"&rrid="
|
nsdomain = tld.domain+"."+tld.suffix
|
||||||
|
|
||||||
|
url = "https://www.namesilo.com/api/dnsDeleteRecord\
|
||||||
|
?version=1&type=xml&key="+apikey+"&domain="+nsdomain+"&rrid="
|
||||||
|
|
||||||
def getrequest(record_id):
|
def getrequest(record_id):
|
||||||
return urllib.request.Request(
|
return urllib.request.Request(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue