mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
fix: extractCertsFromAcmeJson fails if "sans" not in Certificates.domain.main
This commit is contained in:
parent
f206ad7ee1
commit
6bd1fb568e
|
@ -39,9 +39,29 @@ function _sanitize_ipv4_to_subnet_cidr() {
|
||||||
# extracts certificates from acme.json and returns 0 if found
|
# extracts certificates from acme.json and returns 0 if found
|
||||||
function extractCertsFromAcmeJson() {
|
function extractCertsFromAcmeJson() {
|
||||||
WHAT=$1
|
WHAT=$1
|
||||||
# sorry for the code-golf :(
|
|
||||||
KEY=$(cat /etc/letsencrypt/acme.json | python -c "import sys,json,itertools; print map(lambda c: c[\"key\"] if (c[\"domain\"][\"main\"]==\"$WHAT\" or \"$WHAT\" in c[\"domain\"][\"sans\"]) else \"\", list(itertools.chain.from_iterable(map(lambda x: x[\"Certificates\"], json.load(sys.stdin).values()))))[0]")
|
KEY=$(cat /etc/letsencrypt/acme.json | python -c "
|
||||||
CERT=$(cat /etc/letsencrypt/acme.json | python -c "import sys,json,itertools; print map(lambda c: c[\"certificate\"] if (c[\"domain\"][\"main\"]==\"$WHAT\" or \"$WHAT\" in c[\"domain\"][\"sans\"]) else \"\", list(itertools.chain.from_iterable(map(lambda x: x[\"Certificates\"], json.load(sys.stdin).values()))))[0]")
|
import sys,json
|
||||||
|
acme = json.load(sys.stdin)
|
||||||
|
for key, value in acme.items():
|
||||||
|
certs = value['Certificates']
|
||||||
|
for cert in certs:
|
||||||
|
if 'domain' in cert and 'key' in cert:
|
||||||
|
if 'main' in cert['domain'] and cert['domain']['main'] == '$WHAT' or 'sans' in cert['domain'] and '$WHAT' in cert['domain']['sans']:
|
||||||
|
print cert['key']
|
||||||
|
print ''
|
||||||
|
")
|
||||||
|
CERT=$(cat /etc/letsencrypt/acme.json | python -c "
|
||||||
|
import sys,json
|
||||||
|
acme = json.load(sys.stdin)
|
||||||
|
for key, value in acme.items():
|
||||||
|
certs = value['Certificates']
|
||||||
|
for cert in certs:
|
||||||
|
if 'domain' in cert and 'certificate' in cert:
|
||||||
|
if 'main' in cert['domain'] and cert['domain']['main'] == '$WHAT' or 'sans' in cert['domain'] and '$WHAT' in cert['domain']['sans']:
|
||||||
|
print cert['certificate']
|
||||||
|
print ''
|
||||||
|
")
|
||||||
|
|
||||||
if [[ -n "${KEY}${CERT}" ]]; then
|
if [[ -n "${KEY}${CERT}" ]]; then
|
||||||
mkdir -p /etc/letsencrypt/live/"$HOSTNAME"/
|
mkdir -p /etc/letsencrypt/live/"$HOSTNAME"/
|
||||||
|
|
Loading…
Reference in a new issue