diff --git a/target/check-for-changes.sh b/target/check-for-changes.sh index 804d7070..da3e0607 100755 --- a/target/check-for-changes.sh +++ b/target/check-for-changes.sh @@ -1,5 +1,7 @@ #!/bin/bash +. /usr/local/bin/helper_functions.sh + # create date for log output log_date=$(date +"%Y-%m-%d %H:%M:%S ") echo "${log_date} Start check-for-changes script." @@ -32,7 +34,7 @@ echo "${log_date} Using postmaster address ${PM_ADDRESS}" # Create an array of files to monitor, must be the same as in start-mailserver.sh declare -a cf_files=() -for file in postfix-accounts.cf postfix-virtual.cf postfix-aliases.cf dovecot-quotas.cf; do +for file in postfix-accounts.cf postfix-virtual.cf postfix-aliases.cf dovecot-quotas.cf /etc/letsencrypt/acme.json; do [ -f "$file" ] && cf_files+=("$file") done @@ -61,6 +63,10 @@ if [[ $chksum == *"FAIL"* ]]; then ( flock -e 200 + if [[ $chksum == *"/etc/letsencrypt/acme.json: FAILED"* ]]; then + (extractCertsFromAcmeJson "$HOSTNAME" || extractCertsFromAcmeJson "$DOMAINNAME") + fi + #regen postix aliases. echo "root: ${PM_ADDRESS}" > /etc/aliases if [ -f /tmp/docker-mailserver/postfix-aliases.cf ]; then diff --git a/target/helper_functions.sh b/target/helper_functions.sh index 207daef1..24a13829 100644 --- a/target/helper_functions.sh +++ b/target/helper_functions.sh @@ -2,36 +2,54 @@ # expects mask prefix length and the digit function _mask_ip_digit() { - if [[ $1 -ge 8 ]]; then - MASK=255 - else - if [[ $1 -le 0 ]]; then - MASK=0 - else - VALUES=('0' '128' '192' '224' '240' '248' '252' '254' '255') - MASK=${VALUES[$1]} - fi - fi - echo $(( $2 & $MASK )) + if [[ $1 -ge 8 ]]; then + MASK=255 + else + if [[ $1 -le 0 ]]; then + MASK=0 + else + VALUES=('0' '128' '192' '224' '240' '248' '252' '254' '255') + MASK=${VALUES[$1]} + fi + fi + echo $(($2 & $MASK)) } # transforms a specific ip with CIDR suffix like 1.2.3.4/16 # to subnet with cidr suffix like 1.2.0.0/16 function _sanitize_ipv4_to_subnet_cidr() { - IP=${1%%/*} - PREFIX_LENGTH=${1#*/} + IP=${1%%/*} + PREFIX_LENGTH=${1#*/} - # split IP by . into digits - DIGITS=(${IP//./ }) + # split IP by . into digits + DIGITS=(${IP//./ }) - # mask digits according to prefix length - MASKED_DIGITS=() - DIGIT_PREFIX_LENGTH="$PREFIX_LENGTH" - for DIGIT in "${DIGITS[@]}" ; do - MASKED_DIGITS+=( $(_mask_ip_digit $DIGIT_PREFIX_LENGTH $DIGIT) ) - DIGIT_PREFIX_LENGTH=$(( $DIGIT_PREFIX_LENGTH - 8 )) - done + # mask digits according to prefix length + MASKED_DIGITS=() + DIGIT_PREFIX_LENGTH="$PREFIX_LENGTH" + for DIGIT in "${DIGITS[@]}"; do + MASKED_DIGITS+=($(_mask_ip_digit $DIGIT_PREFIX_LENGTH $DIGIT)) + DIGIT_PREFIX_LENGTH=$(($DIGIT_PREFIX_LENGTH - 8)) + done - # output masked ip plus prefix length - echo ${MASKED_DIGITS[0]}.${MASKED_DIGITS[1]}.${MASKED_DIGITS[2]}.${MASKED_DIGITS[3]}/$PREFIX_LENGTH -} \ No newline at end of file + # output masked ip plus prefix length + echo ${MASKED_DIGITS[0]}.${MASKED_DIGITS[1]}.${MASKED_DIGITS[2]}.${MASKED_DIGITS[3]}/$PREFIX_LENGTH +} + +# extracts certificates from acme.json and returns 0 if found +function extractCertsFromAcmeJson() { + 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]") + 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]") + + if [[ -n "${KEY}${CERT}" ]]; then + mkdir -p /etc/letsencrypt/live/"$HOSTNAME"/ + echo $KEY | base64 -d >/etc/letsencrypt/live/"$HOSTNAME"/key.pem || exit 1 + echo $CERT | base64 -d >/etc/letsencrypt/live/"$HOSTNAME"/fullchain.pem || exit 1 + echo "Cert found in /etc/letsencrypt/acme.json for $WHAT" + return 0 + else + return 1 + fi +} diff --git a/target/start-mailserver.sh b/target/start-mailserver.sh index 7f56923e..932b00b1 100644 --- a/target/start-mailserver.sh +++ b/target/start-mailserver.sh @@ -505,7 +505,7 @@ function _setup_chksum_file() { pushd /tmp/docker-mailserver declare -a cf_files=() - for file in postfix-accounts.cf postfix-virtual.cf postfix-aliases.cf dovecot-quotas.cf; do + for file in postfix-accounts.cf postfix-virtual.cf postfix-aliases.cf dovecot-quotas.cf /etc/letsencrypt/acme.json; do [ -f "$file" ] && cf_files+=("$file") done @@ -1048,6 +1048,8 @@ function _setup_ssl() { local LETSENCRYPT_DOMAIN="" local LETSENCRYPT_KEY="" + [[ -f /etc/letsencrypt/acme.json ]] && (extractCertsFromAcmeJson "$HOSTNAME" || extractCertsFromAcmeJson "$DOMAINNAME") + # first determine the letsencrypt domain by checking both the full hostname or just the domainname if a SAN is used in the cert if [ -e "/etc/letsencrypt/live/$HOSTNAME/fullchain.pem" ]; then LETSENCRYPT_DOMAIN=$HOSTNAME diff --git a/test/config/letsencrypt/acme-changed.json b/test/config/letsencrypt/acme-changed.json new file mode 100644 index 00000000..0e05482a --- /dev/null +++ b/test/config/letsencrypt/acme-changed.json @@ -0,0 +1,31 @@ +{ + "le": { + "Account": { + "Email": "acme@admin.com", + "Registration": { + "body": { + "status": "valid", + "contact": [ + "mailto:acme@admin.com" + ] + }, + "uri": "https://acme-v02.api.letsencrypt.org/acme/acct/0123456789" + }, + "PrivateKey": "YES", + "KeyType": "4096" + }, + "Certificates": [ + { + "domain": { + "main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ThxZmhWa1NWNFg3bDNycXk3eUNQNEc1MXBaQ1dWcDl6WQo4UzNtYmlDM3hYVjZpTzVQeGVoS1ZmdnFySXF6MnpaWDhTRjFhMUwzekRGQ3BFNkdmUHB5Uk1uK01hLy84b3haCmRwdGV6WlRCMVJtUDd6UndIVGJrSXhjU3NuYkVUOWNuZDc1ck9OSkZBb0dCQU0wQm0xZFFONW13TU5HMWhQSmkKSWNtc212QTYzbEE2eUtTMnBxbndXemNqb2NScnNWZ1hzZzJEdk1xb2hhU21RWUxUazE4OVFNbnkxa1RZY1J3SwowcG1RVG5Rbkp2OWYvek1ndEJmRzM3akdnY2NiM1lHV01zdmh6TCtobWd2cVN2SHVYQWRENEZNdlhIRi9HYktjCmQycGI1cjlGc3kyQUJJekxVeVNsMU02SEFvR0FCQUxneHZYelhGaG92VFBZbTRsZlc4Y1JXWE5pNnB3cmdZZVoKRlgyS0N3bHVTa2RuZnRuSnUwY0lMdEZsakFlRHRiKzRueVluZ1lxT2NMd0RzVnh5YVNYTXNlQlVrL2ZsNXlJKwptV0JFeGdabzEzZ3gyYzJEQm5keWYrY1UwaVk5bEtsYTR1VTFGTTRLMjVkeXdrZVpubmRYYU9nY0lwdnZ5aTVsCmpiR1RFMDBDZ1lBVCtVTm9tcDhKbW01YXFDME1kc050OW13T0tMVnRDazFZei9YODVQbVNpU1p4eG11cThVNXUKYThvYUovTm1tTXBZc1JHOXB5NW1JZ0RXSDFicnlPWlA3YVB0T0lWWnBZSDc3cU1ySjR2RmJ6MkphQTFiMWlySgoyMkhkajFYRDdMdjJ1cXQ3UVVsYU5RY3VrSkZJSE94WVJOWUNobEpuSUVmMmU3MGpkbEN4TGc9PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo=", + "Store": "default" + } + ] + } +} diff --git a/test/config/letsencrypt/acme.json b/test/config/letsencrypt/acme.json new file mode 100644 index 00000000..244d058a --- /dev/null +++ b/test/config/letsencrypt/acme.json @@ -0,0 +1,31 @@ +{ + "le": { + "Account": { + "Email": "acme@admin.com", + "Registration": { + "body": { + "status": "valid", + "contact": [ + "mailto:acme@admin.com" + ] + }, + "uri": "https://acme-v02.api.letsencrypt.org/acme/acct/0123456789" + }, + "PrivateKey": "YES", + "KeyType": "4096" + }, + "Certificates": [ + { + "domain": { + "main": "mail.my-domain.com", + "sans": [ + "mail2.my-domain.com" + ] + }, + "certificate": "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUZHVENDQkFHZ0F3SUJBZ0lTQTUwamo2QS9pbEV4TWxhNDFQd1NlanlCTUEwR0NTcUdTSWIzRFFFQkN3VUEKTUVveEN6QUpCZ05WQkFZVEFsVlRNUll3RkFZRFZRUUtFdzFNWlhRbmN5QkZibU55ZVhCME1TTXdJUVlEVlFRRApFeHBNWlhRbmN5QkZibU55ZVhCMElFRjFkR2h2Y21sMGVTQllNekFlRncweE5qQTBNVGt4T1RBMU1EQmFGdzB4Ck5qQTNNVGd4T1RBMU1EQmFNQlV4RXpBUkJnTlZCQU1UQ21sbWRYTnBieTVqYjIwd2dnRWlNQTBHQ1NxR1NJYjMKRFFFQkFRVUFBNElCRHdBd2dnRUtBb0lCQVFDY0NsZitQZWUxRUl0ZG5qYWdPVVF1d0E0U0xMaUtDZjVUKzJFYwpCUG53TUdLdERiL1RCV2M4S0VIUUd4WUNkdGFtRmNpVCtPWFVsSkdqUEdFbmE0REFLQU5pNW5qbXErVFFGYjdKCmlwQTdwZlE0ZnAvMk9xRzNlNlN3TnZXdXJKbEhJaWdpTGUxbGJjKzdydC81aG9uN0p3bjI2MHgvWGFQSFhSa1UKQWl5NUZTRFZlWG5uQ0w1UU91NXNybkhyZFRsV3BFbno5V1V2WUNqM0RNUjM4Z3hvam5tcGo0OGFNUlJ0ckJBTwpObHhUOVRzc0hvS3ZEWEkxYkViZWIydHBtQy8ra1JQdXNJdWtpdWNjM0ZvOVIvc0hYakZrRDdtSzJVTWIwVUxFCkJHMkQ0d3dFSU5VU0czQjN3c3UwZ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2OXErRnpFWHFFK0hzZkQzQgprQmZaOEdaenRRS0JnRVZTZHc2L3ZqcGR4Vjlsck13czEwZnhvTjRUckFhSTVKWTBUTTcxS1RseWJXV1MxcUxyCmRaM3JpV0NmQUhLU2JJazcwK3AvS3RDVUtiUnZpZDlNNEFxVUtXWXkyQTBCVzhJYkV6MEs4REZvdVBQVWtTRW8KY000cG9aenBuK1pTM2xuY055UWNaSFZBTUpzTnBMV0Jja25ZcVZaNHUwajBXSlpaUkRzT1E4dEJBb0dCQUsycApCSDkraUZJL1pHNUliQ0RCZHI2eDFOaHF4UWsvR095elU0c3kwVjgxajFPTWlhZ0NBTWxxZTBwNmcvVWFZNFNWCittWC81UGo1R3ZNODRpeUQvTitkWVZqdzd3RUpiekdXdEttNUxKZnJUMHBNV0ZHRHJsdUUzdVZ3Vmx3V2lobjcKTmFlY3VhdFJ4eWh4azdPNzZVNFBIdVFrQXNkckZpK3lEY2V0TEpJQkFvR0JBSkhVTXR0S1E5L3NjNkVZZ2R5bQp1OGhNaS9XR3J0NWVPT0FKMTdsWTUzZVJaTGNpN3MxbWZzV0lGOWIwTjUwaUU2MFNhRkFEUWlNUkFVdGtKWE5JCmE1NXFkcGFsVkhzQUU0V3doN25sS0xrYURFYXJ0eDVYMXFTVEZ3NGZUTXlLTk92ZWlnZ1EvaTlMWnBGeHN6MjIKM1YrN2pQSmFDTnlQYm1PZXZYR2hCRWpyCi0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0=", + "Store": "default" + } + ] + } +} diff --git a/test/config/letsencrypt/changed/cert.pem b/test/config/letsencrypt/changed/cert.pem new file mode 100644 index 00000000..aecb192c --- /dev/null +++ b/test/config/letsencrypt/changed/cert.pem @@ -0,0 +1,18 @@ +-----BEGIN CERTIFICATE----- +MIIC5DCCAcygAwIBAgIJAN/+3LMQvnv1MA0GCSqGSIb3DQEBCwUAMBIxEDAOBgNV +BAMMB3Rlc3QtY2EwHhcNMjAwNjI5MjA1NTIxWhcNMjAwODI4MjA1NTIxWjAWMRQw +EgYDVQQDDAtleGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC +ggEBAL5UNg7ybrXoCInmxQ+f38++sLEcgG6P0X+faH11Bw47Vt+mf1vltIh7ojO8 +DeXqFxsGL3S/YqyuXX0TGIOh/csjnvv1GEL1Ux0YCsyFkvflb8NuSKW52T0dnUqF +ZFwldykCwHnQxmwYZxnZjVF2YOr/KmGZvO5dxSTs/qDuU0cp3FD4z2CBELLmzixv +fO2Lgk1Yn/H9mNLNSKQaiSeCxId5CzNIlmUIfnL0tuc3n2fNigjuPKOV2H/7NVTT +TriuP384bx9WTLfX29cn+Ho4hKBaq2t1Wmz+jsWi1gya1KrLAM4zzQHI+u6r3+jS +3PsRVs1csyO2NCXqVo/bxqe38+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8E +BAMCBeAwHQYDVR0lBBYwFAYIKwYBBQUHAwIGCCsGAQUFBwMBMA0GCSqGSIb3DQEB +CwUAA4IBAQAkmHHTaZ8hiStoA/XYjGXkHT5DBjjOhRm3mmdCF+xhbUcj/frwBYn0 +apAGfNSGq+PJTgVdsZUAC+sOfxRme3FjU5gAekeIDjOQMd1VbdmcIWtnJ+Ttz94F +Qm5V7Df8kVkcqE6UvvXyX3YEFj2/fwb4hxyyl/fAWl5acWTLNA2mOKm/fMhKez+h +3VGhKQ5ZGS0Qt+Lea3o7LWs5dH5LhSvs3Fe9PSddxa0Nbtr4sfgfOIQJgo2mCvch +u5zFq7nvDqdsmdZwYMIcinpPWJgEoQLJWU/gWL2Ya+5kJ137smPcYX7jDSyBHlkQ +oAYOB65YnoWxVuQtKqHW6f8nqD1nwEBn +-----END CERTIFICATE----- diff --git a/test/config/letsencrypt/changed/fullchain.pem b/test/config/letsencrypt/changed/fullchain.pem new file mode 100644 index 00000000..ee19d130 --- /dev/null +++ b/test/config/letsencrypt/changed/fullchain.pem @@ -0,0 +1,36 @@ +-----BEGIN CERTIFICATE----- +M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/config/letsencrypt/changed/key.pem b/test/config/letsencrypt/changed/key.pem new file mode 100644 index 00000000..727fcf31 --- /dev/null +++ b/test/config/letsencrypt/changed/key.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAvlQ2DvJutegIiebFD5/fz76wsRyAbo/Rf59ofXUHDjtW36Z/ +W+W0iHuiM7wN5eoXGwYvdL9irK5dfRMYg6H9yyOe+/UYQvVTHRgKzIWS9+Vvw25I +pbnZPR2dSoVkXCV3KQLAedDGbBhnGdmNUXZg6v8qYZm87l3FJOz+oO5TRyncUPjP +YIEQsubOLG987YuCTVif8f2Y0s1IpBqJJ4LEh3kLM0iWZQh+cvS25zefZ82KCO48 +o5XYf/s1VNNOuK4/fzhvH1ZMt9fb1yf4ejiEoFqra3VabP6OxaLWDJrUqssAzjPN +Acj67qvf6NLc+xFWzVyzI7Y0JepWj9vGp7fz6wIDAQABAoIBAQCufh4hjfoaI+TQ +KRY5wOU8XSM4/VxyAMCdNNRjUMtrLNP0r3zMD8h36IFI1PwY8YjFaeJQMraQgjuL +09oBtJ4tgzba4FWh7bCJV+VupHeddmgE0DMiXUThVylBjRH5uQ+KNc+o3tNLfwPn +GyEIsnMgf1enq38fOjDoLa80c8s9zXhHtZx9JQzDUbQr+DNTS0RLP52MI/pXGC+g +T225sVV39uqQFccHECacLDbYe5EhzRi2PNA98fHtO/lAP9jjvQiMccr0KjjzEHlS +loFs1/y/vCAo/kThqhKL/0T3qdiG+YNsne+Thy2xx5W37YMGIte9f+5ymTmb+lgb +fU6/i2thAoGBAPO6Urt50h3vJ2m/+MFCkokca195k9sYO1RMkTYHPZ5n4+nTu32o +RDKu/KwOgly9cp00Qn8XIcDi7Mut8MK7RGv1WyZVlbX1+L31FT+c/N96rHBa5SHI +nhdTLBLPTmb6OOPSWXEHl00vsltAlutIrufjzowEtgptOhYO8a608ihvAoGBAMfp +kiu/0bl7cQgYfgfIfyc2iMOZSDlyTEE8qfhVkSV4X7l3rqy7yCP4G51pZCWVp9zY +8S3mbiC3xXV6iO5PxehKVfvqrIqz2zZX8SF1a1L3zDFCpE6GfPpyRMn+Ma//8oxZ +dptezZTB1RmP7zRwHTbkIxcSsnbET9cnd75rONJFAoGBAM0Bm1dQN5mwMNG1hPJi +IcmsmvA63lA6yKS2pqnwWzcjocRrsVgXsg2DvMqohaSmQYLTk189QMny1kTYcRwK +0pmQTnQnJv9f/zMgtBfG37jGgccb3YGWMsvhzL+hmgvqSvHuXAdD4FMvXHF/GbKc +d2pb5r9Fsy2ABIzLUySl1M6HAoGABALgxvXzXFhovTPYm4lfW8cRWXNi6pwrgYeZ +FX2KCwluSkdnftnJu0cILtFljAeDtb+4nyYngYqOcLwDsVxyaSXMseBUk/fl5yI+ +mWBExgZo13gx2c2DBndyf+cU0iY9lKla4uU1FM4K25dywkeZnndXaOgcIpvvyi5l +jbGTE00CgYAT+UNomp8Jmm5aqC0MdsNt9mwOKLVtCk1Yz/X85PmSiSZxxmuq8U5u +a8oaJ/NmmMpYsRG9py5mIgDWH1bryOZP7aPtOIVZpYH77qMrJ4vFbz2JaA1b1irJ +22Hdj1XD7Lv2uqt7QUlaNQcukJFIHOxYRNYChlJnIEf2e70jdlCxLg== +-----END RSA PRIVATE KEY----- diff --git a/test/mail_ssl_letsencrypt.bats b/test/mail_ssl_letsencrypt.bats index 01c7a742..1f67d45d 100644 --- a/test/mail_ssl_letsencrypt.bats +++ b/test/mail_ssl_letsencrypt.bats @@ -26,11 +26,24 @@ function setup_file() { -e SSL_TYPE=letsencrypt \ -h mail.my-domain.com -t ${NAME} wait_for_finished_setup_in_container mail_lets_hostname + + cp "`pwd`/test/config/letsencrypt/acme.json" "`pwd`/test/config/acme.json" + docker run -d --name mail_lets_acme_json \ + -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "`pwd`/test/config/acme.json":/etc/letsencrypt/acme.json:ro \ + -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -e DMS_DEBUG=0 \ + -e SSL_TYPE=letsencrypt \ + -h mail.my-domain.com -t ${NAME} + + wait_for_finished_setup_in_container mail_lets_acme_json } function teardown_file() { docker rm -f mail_lets_domain docker rm -f mail_lets_hostname + docker rm -f mail_lets_acme_json + rm "`pwd`/test/config/acme.json" } # this test must come first to reliably identify when to run setup_file @@ -78,6 +91,44 @@ function teardown_file() { assert_success } +# +# acme.json updates +# + +@test "checking changedetector: server is ready" { + run docker exec mail_lets_acme_json /bin/bash -c "ps aux | grep '/bin/bash /usr/local/bin/check-for-changes.sh'" + assert_success +} + +@test "can extract certs from acme.json" { + run docker exec mail_lets_acme_json /bin/bash -c "cat /etc/letsencrypt/live/mail.my-domain.com/key.pem" + assert_output "$(cat "`pwd`/test/config/letsencrypt/mail.my-domain.com/privkey.pem")" + assert_success + + run docker exec mail_lets_acme_json /bin/bash -c "cat /etc/letsencrypt/live/mail.my-domain.com/fullchain.pem" + assert_output "$(cat "`pwd`/test/config/letsencrypt/mail.my-domain.com/fullchain.pem")" + assert_success +} + +@test "can detect changes" { + cp "`pwd`/test/config/letsencrypt/acme-changed.json" "`pwd`/test/config/acme.json" + sleep 11 + run docker exec mail_lets_acme_json /bin/bash -c "supervisorctl tail changedetector" + assert_output --partial "Cert found in /etc/letsencrypt/acme.json for mail.my-domain.com" + assert_output --partial "postfix: stopped" + assert_output --partial "postfix: started" + assert_output --partial "Update checksum" + + run docker exec mail_lets_acme_json /bin/bash -c "cat /etc/letsencrypt/live/mail.my-domain.com/key.pem" + assert_output "$(cat "`pwd`/test/config/letsencrypt/changed/key.pem")" + assert_success + + run docker exec mail_lets_acme_json /bin/bash -c "cat /etc/letsencrypt/live/mail.my-domain.com/fullchain.pem" + assert_output "$(cat "`pwd`/test/config/letsencrypt/changed/fullchain.pem")" + assert_success +} + + # this test is only there to reliably mark the end for the teardown_file @test "last" { skip 'Finished testing of letsencrypt SSL'