diff --git a/.idea/namesilo-letsencrypt.iml b/.idea/namesilo-letsencrypt.iml index 01981e5..ddc01a4 100644 --- a/.idea/namesilo-letsencrypt.iml +++ b/.idea/namesilo-letsencrypt.iml @@ -7,7 +7,7 @@ - + \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..0a79563 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,25 @@ +# Changelog + +## [0.9.2](https://github.com/ethauvin/namesilo-letsencrypt/tree/0.9.2) (2020-05-28) + +[Full Changelog](https://github.com/ethauvin/namesilo-letsencrypt/compare/0.9.1...0.9.2) + +**Closed issues:** + +- Do not support multiple \_acme-challenge records [\#1](https://github.com/ethauvin/namesilo-letsencrypt/issues/1) + +**Merged pull requests:** + +- make python3.4 compatible. add subdomains support [\#2](https://github.com/ethauvin/namesilo-letsencrypt/pull/2) ([Junker](https://github.com/Junker)) + +## [0.9.1](https://github.com/ethauvin/namesilo-letsencrypt/tree/0.9.1) (2020-03-15) + +[Full Changelog](https://github.com/ethauvin/namesilo-letsencrypt/compare/0.9.0...0.9.1) + +## [0.9.0](https://github.com/ethauvin/namesilo-letsencrypt/tree/0.9.0) (2019-04-30) + +[Full Changelog](https://github.com/ethauvin/namesilo-letsencrypt/compare/8a91146faebd196b223f7653e470428130f26246...0.9.0) + + + +\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* diff --git a/README.md b/README.md index 79ab273..3e2232a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # NameSilo Let's Encrypt -[![License (3-Clause BSD)](https://img.shields.io/badge/license-BSD%203--Clause-blue.svg?style=flat-square)](http://opensource.org/licenses/BSD-3-Clause) -[![Python 3.8](https://img.shields.io/badge/python-3.8-blue.svg)](https://www.python.org/) +[![License (3-Clause BSD)](https://img.shields.io/badge/license-BSD%203--Clause-blue.svg?style=flat-square)](https://opensource.org/licenses/BSD-3-Clause) +[![Python 3.4](https://img.shields.io/badge/python-3.4-blue.svg)](https://www.python.org/) Python scripts (hook) to automate obtaining [Let's Encrypt](https://letsencrypt.org/) certificates, using [Certbot](https://certbot.eff.org/) DNS-01 challenge validation for domains DNS hosted on @@ -9,22 +9,21 @@ using [Certbot](https://certbot.eff.org/) DNS-01 challenge validation for domain ## Setup -The scripts use the [untangle](https://untangle.readthedocs.io/en/latest/) library, if not already installed on your system: +The scripts use the [tldextract](https://github.com/john-kurkowski/tldextract) and [untangle](https://untangle.readthedocs.io/en/latest/) libraries, if not already installed on your system: ``` -pip install untangle +pip install tldextract untangle ``` Download the [latest release](https://github.com/ethauvin/namesilo-letsencrypt/releases) archive and expand it in the desired directory. - ## Configuration -Add your [NameSilo API key](https://www.namesilo.com/account_api.php) +Add your [NameSilo API key](https://www.namesilo.com/account/api-manager) to the top of the `config.py` file: ```python -# Get your API Key from: https://www.namesilo.com/account_api.php +# Get your API Key from: https://www.namesilo.com/account/api-manager apikey = "YOUR_API_KEY" ``` @@ -43,4 +42,4 @@ certbot certonly --manual --email you@example.com \ -d *.example.com -d example.com -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 **25 minutes** before completing, just to be safe. diff --git a/authenticator.py b/authenticator.py old mode 100644 new mode 100755 index c6fb9bd..510aa1f --- a/authenticator.py +++ b/authenticator.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3.8 +#!/usr/bin/env python3 # authenticator.py # @@ -37,6 +37,7 @@ import tempfile import time import urllib.request +import tldextract import untangle from config import apikey, wait @@ -45,28 +46,32 @@ from config import apikey, wait def sleep(minutes): if minutes < 16: minutes = 16 - print("Waiting", minutes, "minutes for DNS changes to complete...") time.sleep(minutes * 60) domain = os.environ['CERTBOT_DOMAIN'] validation = os.environ['CERTBOT_VALIDATION'] -tmpdir = os.path.join(tempfile.gettempdir(), f"CERTBOT_{domain}") +tmpdir = os.path.join(tempfile.gettempdir(), "CERTBOT_" + domain) +rrhost = "_acme-challenge" if "NAMESILO_API" in os.environ: apikey = os.environ['NAMESILO_API'] -url = f"https://www.namesilo.com/api/dnsAddRecord?\ -version=1&type=xml&key={apikey}&domain={domain}&rrtype=TXT\ -&rrhost=_acme-challenge&rrvalue={validation}&rrttl=3600" +tld = tldextract.extract(domain) +nsdomain = tld.domain + "." + tld.suffix +if tld.subdomain: + rrhost += "." + tld.subdomain + +url = "https://www.namesilo.com/api/dnsAddRecord?\ +version=1&type=xml&key=" + apikey + "&domain=" + nsdomain + "&rrtype=TXT\ +&rrhost=" + rrhost + "&rrvalue=" + validation + "&rrttl=3600" req = urllib.request.Request( url, data=None, headers={ - 'User-Agent': ('Mozilla/5.0 (X11; CrOS x86_64 11647.154.0) ' - 'AppleWebKit/537.36 (KHTML, like Gecko) ' - 'Chrome/73.0.3683.114 Safari/537.36') + 'User-Agent': ('Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) ' + 'Gecko/20100101 Firefox/74.0') } ) diff --git a/cleanup.py b/cleanup.py old mode 100644 new mode 100755 index 627560a..c15d05c --- a/cleanup.py +++ b/cleanup.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3.8 +#!/usr/bin/env python3 # cleanup.py # @@ -36,18 +36,22 @@ import sys import tempfile import urllib.request +import tldextract import untangle from config import apikey domain = os.environ['CERTBOT_DOMAIN'] -tmpdir = os.path.join(tempfile.gettempdir(), f"CERTBOT_{domain}") +tmpdir = os.path.join(tempfile.gettempdir(), "CERTBOT_" + domain) if "NAMESILO_API" in os.environ: apikey = os.environ['NAMESILO_API'] -url = f"https://www.namesilo.com/api/dnsDeleteRecord\ -?version=1&type=xml&key={apikey}&domain={domain}&rrid=" +tld = tldextract.extract(domain) +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): @@ -55,9 +59,8 @@ def getrequest(record_id): url + record_id, data=None, headers={ - 'User-Agent': ('Mozilla/5.0 (X11; CrOS x86_64 11647.154.0) ' - 'AppleWebKit/537.36 (KHTML, like Gecko) ' - 'Chrome/73.0.3683.114 Safari/537.36') + 'User-Agent': ('Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) ' + 'Gecko/20100101 Firefox/74.0') } ) diff --git a/config.py b/config.py index 8679450..0bcd226 100644 --- a/config.py +++ b/config.py @@ -1,4 +1,4 @@ -# Get your API Key from: https://www.namesilo.com/account_api.php +# Get your API Key from: https://www.namesilo.com/account/api-manager apikey = "YOUR_API_KEY" # Minutes to wait for DNS changes to complete. -wait = 20 +wait = 25 diff --git a/release.sh b/release.sh new file mode 100755 index 0000000..6689a1b --- /dev/null +++ b/release.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +RELEASE=release + +if [ $# != 1 ]; +then + echo "Usage: $(basename "$0") " + exit 2 +else + if ! [ -d "$RELEASE" ] + then + mkdir "$RELEASE" + fi + PROJECT=$(basename "$(pwd)") + DIR="${PROJECT}-${1}" + mkdir "$DIR" + cp ./*.py ./*.md ./*.txt "$DIR" + dos2unix "$DIR"/*.* + touch "$DIR" "$DIR"/*.* + tar -czvf "${RELEASE}/${DIR}.tar.gz" "$DIR" + zip --to-crlf -r "${RELEASE}/${DIR}.zip" "$DIR" + touch "$RELEASE"/*.* + rm -rf "${DIR}" +fi diff --git a/release/namesilo-letsencrypt-0.9.2.tar.gz b/release/namesilo-letsencrypt-0.9.2.tar.gz new file mode 100644 index 0000000..711d070 Binary files /dev/null and b/release/namesilo-letsencrypt-0.9.2.tar.gz differ diff --git a/release/namesilo-letsencrypt-0.9.2.zip b/release/namesilo-letsencrypt-0.9.2.zip new file mode 100644 index 0000000..4affb98 Binary files /dev/null and b/release/namesilo-letsencrypt-0.9.2.zip differ