276
276
# 2021-10-01 Show help if no domain specified (#705)(2.44)
277
277
# 2021-10-08 Extract release tag from release api using awk (fix BSD issues)
278
278
# 2021-10-11 Fix broken upgrade url (#718)(2.45)
279
+ # 2021-10-22 Copy fullchain to DOMAIN_CHAIN_LOCATION (amartin-git)
280
+ # 2021-11-10 Detect Solaris and use gnu tools (#701)(miesi)
281
+ # 2021-11-12 Support acme-dns and fix CNAME issues (#722)(#308)
279
282
# ----------------------------------------------------------------------------------------
280
283
281
284
case :$SHELLOPTS : in
@@ -536,12 +539,6 @@ check_challenge_completion() { # checks with the ACME server if our challenge is
536
539
debug " sleep 5 secs before testing verify again"
537
540
sleep 5
538
541
done
539
-
540
- if [[ " $DEACTIVATE_AUTH " == " true" ]]; then
541
- deactivate_url=$( echo " $responseHeaders " | grep " ^Link" | awk -F" [<>]" ' {print $2}' )
542
- deactivate_url_list=" $deactivate_url_list $deactivate_url "
543
- debug " adding url to deactivate list - $deactivate_url "
544
- fi
545
542
}
546
543
547
544
check_challenge_completion_dns () { # perform validation via DNS challenge
@@ -575,10 +572,19 @@ check_challenge_completion_dns() { # perform validation via DNS challenge
575
572
# shellcheck disable=SC2086
576
573
debug " $DNS_CHECK_FUNC " $DNS_CHECK_OPTIONS TXT " ${rr} " " @${ns} "
577
574
# shellcheck disable=SC2086
578
- check_result=$( $DNS_CHECK_FUNC $DNS_CHECK_OPTIONS TXT " ${rr} " " @${ns} " \
579
- | grep -i " ^${rr} " \
580
- | grep ' IN\WTXT' | awk -F' "' ' { print $2}' )
575
+ check_output=$( $DNS_CHECK_FUNC $DNS_CHECK_OPTIONS TXT " ${rr} " " @${ns} " )
576
+ check_result=$( grep -i " ^${rr} " <<< " ${check_output}" | grep ' IN\WTXT' | awk -F' "' ' { print $2}' )
581
577
debug " check_result=\" $check_result \" "
578
+
579
+ # Check if rr is a CNAME
580
+ if [[ -z " $check_result " ]]; then
581
+ rr_cname=$( grep -i " ^${rr} " <<< " ${check_output}" | grep ' IN\WCNAME' | awk ' { print $5}' )
582
+ debug " cname check=\" $rr_cname \" "
583
+ if [[ -n " $rr_cname " ]]; then
584
+ check_result=$( grep -i " ^${rr_cname} " <<< " ${check_output}" | grep ' IN\WTXT' | awk -F' "' ' { print $2}' | uniq)
585
+ fi
586
+ fi
587
+
582
588
if [[ -z " $check_result " ]]; then
583
589
# shellcheck disable=SC2086
584
590
debug " $DNS_CHECK_FUNC " $DNS_CHECK_OPTIONS ANY " ${rr} " " @${ns} "
@@ -589,14 +595,20 @@ check_challenge_completion_dns() { # perform validation via DNS challenge
589
595
debug " check_result=\" $check_result \" "
590
596
fi
591
597
elif [[ " $DNS_CHECK_FUNC " == " host" ]]; then
598
+ debug " $DNS_CHECK_FUNC " -t TXT " ${rr} " " ${ns} "
592
599
check_result=$( $DNS_CHECK_FUNC -t TXT " ${rr} " " ${ns} " \
593
600
| grep ' descriptive text' | awk -F' "' ' { print $2}' )
601
+ debug " check_result=\" $check_result \" "
594
602
else
603
+ debug " $DNS_CHECK_FUNC " -type=txt " ${rr} " " ${ns} "
595
604
check_result=$( nslookup -type=txt " ${rr} " " ${ns} " \
596
605
| grep ' text =' | awk -F' "' ' { print $2}' )
606
+ debug " check_result=\" $check_result \" "
597
607
if [[ -z " $check_result " ]]; then
608
+ debug " $DNS_CHECK_FUNC " -type=any " ${rr} " " ${ns} "
598
609
check_result=$( nslookup -type=any " ${rr} " " ${ns} " \
599
610
| grep ' text =' | awk -F' "' ' { print $2}' )
611
+ debug " check_result=\" $check_result \" "
600
612
fi
601
613
fi
602
614
debug " expecting \" $auth_key \" "
@@ -1201,6 +1213,11 @@ create_order() {
1201
1213
fi
1202
1214
(( dn++ ))
1203
1215
done
1216
+ if [[ " $DEACTIVATE_AUTH " == " true" ]]; then
1217
+ deactivate_url_list+=" $l "
1218
+ debug " url added to deactivate list ${l} "
1219
+ debug " deactivate list is now $deactivate_url_list "
1220
+ fi
1204
1221
done
1205
1222
fi
1206
1223
}
@@ -1352,12 +1369,6 @@ for d in "${alldomains[@]}"; do
1352
1369
1353
1370
if [[ $response_status == " valid" ]]; then
1354
1371
info " $d is already validated"
1355
- if [[ " $DEACTIVATE_AUTH " == " true" ]]; then
1356
- deactivate_url=" $( echo " $responseHeaders " | awk ' $1 ~ "^Location" {print $2}' | tr -d " \r" ) "
1357
- deactivate_url_list+=" $deactivate_url "
1358
- debug " url added to deactivate list ${deactivate_url} "
1359
- debug " deactivate list is now $deactivate_url_list "
1360
- fi
1361
1372
# increment domain-counter
1362
1373
(( dn++ ))
1363
1374
else
@@ -1554,6 +1565,7 @@ get_auth_dns() { # get the authoritative dns server for a domain (sets primary_n
1554
1565
# domain is a CNAME: resolve it and continue with that
1555
1566
debug Domain is a CNAME, actual domain is " $cname "
1556
1567
gad_d=${cname}
1568
+ res=
1557
1569
fi
1558
1570
1559
1571
# Use SOA +trace to find the name server
@@ -1629,6 +1641,7 @@ get_auth_dns() { # get the authoritative dns server for a domain (sets primary_n
1629
1641
primary_ns=" $primary_ns $PUBLIC_DNS_SERVER "
1630
1642
fi
1631
1643
1644
+ debug set primary_ns=" $primary_ns "
1632
1645
return
1633
1646
fi
1634
1647
fi
@@ -1639,26 +1652,48 @@ get_auth_dns() { # get the authoritative dns server for a domain (sets primary_n
1639
1652
# shellcheck disable=SC2086
1640
1653
res=$( nslookup $DNS_CHECK_OPTIONS -debug -type=soa -type=ns " $gad_d " ${gad_s} )
1641
1654
1655
+ # check for CNAME (assumes gad_d is _acme-challenge.{host})
1656
+ if [[ " $( grep -c " NXDOMAIN" <<< " $res" ) " -gt 0 ]]; then
1657
+ debug " Cannot find nameserver record for $gad_d , using parent domain ${gad_d#* .} "
1658
+ gad_d=" ${gad_d#* .} "
1659
+ debug " nslookup $DNS_CHECK_OPTIONS -debug -type=soa -type=ns $gad_d ${gad_s} "
1660
+ # shellcheck disable=SC2086
1661
+ res=$( nslookup $DNS_CHECK_OPTIONS -debug -type=soa -type=ns " $gad_d " ${gad_s} )
1662
+ fi
1663
+
1642
1664
if [[ " $( echo " $res " | grep -c " Non-authoritative" ) " -gt 0 ]]; then
1643
1665
# this is a Non-authoritative server, need to check for an authoritative one.
1666
+ debug " Response from non-authoritative server looking for authoritative server"
1667
+
1644
1668
gad_s=$( echo " $res " | awk ' $2 ~ "nameserver" {print $4; exit }' | sed ' s/\.$//g' )
1645
- if [[ " $( echo " $res " | grep -c " an't find" ) " -gt 0 ]]; then
1669
+ # If the previous line fails to find the nameserver, use the original
1670
+ if [[ -z " $gad_s " ]]; then
1671
+ gad_s=" $orig_gad_s "
1672
+ fi
1673
+
1674
+ if [[ " $( echo " $res " | grep -c " canonical name" ) " -gt 0 ]]; then
1675
+ debug " $gad_d " appears to be a CNAME
1676
+ gad_d=$( echo " $res " | awk ' $2 ~ "canonical" {print $5; exit }' | sed ' s/\.$//g' )
1677
+ debug " Using $gad_d instead"
1678
+ elif [[ " $( echo " $res " | grep -c " an't find" ) " -gt 0 ]]; then
1646
1679
# if domain name doesn't exist, then find auth servers for next level up
1680
+ debug " Couldn't find NS or SOA for domain name, using nslookup $DNS_CHECK_OPTIONS -debug ${gad_d#* .} ${orig_gad_s} "
1681
+ # shellcheck disable=SC2086
1682
+ res=$( nslookup $DNS_CHECK_OPTIONS -debug " ${gad_d#* .} " ${orig_gad_s} )
1647
1683
gad_s=$( echo " $res " | awk ' $1 ~ "origin" {print $3; exit }' )
1648
1684
gad_d=$( echo " $res " | awk ' $1 ~ "->" {print $2; exit}' )
1649
1685
# handle scenario where awk returns nothing
1650
1686
if [[ -z " $gad_d " ]]; then
1651
- gad_d=" $orig_gad_d "
1687
+ gad_d=" ${ orig_gad_d} "
1652
1688
fi
1653
1689
fi
1654
1690
1691
+ debug " Using nslookup $DNS_CHECK_OPTIONS -debug -type=soa -type=ns $gad_d ${gad_s} "
1655
1692
# shellcheck disable=SC2086
1656
1693
res=$( nslookup $DNS_CHECK_OPTIONS -debug -type=soa -type=ns " $gad_d " ${gad_s} )
1657
1694
fi
1658
1695
1659
- if [[ " $( echo " $res " | grep -c " canonical name" ) " -gt 0 ]]; then
1660
- gad_d=$( echo " $res " | awk ' $2 ~ "canonical" {print $5; exit }' | sed ' s/\.$//g' )
1661
- elif [[ " $( echo " $res " | grep -c " an't find" ) " -gt 0 ]]; then
1696
+ if [[ " $( echo " $res " | grep -c " an't find" ) " -gt 0 ]]; then
1662
1697
gad_s=$( echo " $res " | awk ' $1 ~ "origin" {print $3; exit }' )
1663
1698
gad_d=$( echo " $res " | awk ' $1 ~ "->" {print $2; exit}' )
1664
1699
# handle scenario where awk returns nothing
@@ -1680,6 +1715,11 @@ get_auth_dns() { # get the authoritative dns server for a domain (sets primary_n
1680
1715
primary_ns=$( echo " $all_auth_dns_servers " | awk ' {print $1}' )
1681
1716
fi
1682
1717
1718
+ if [[ " $CHECK_PUBLIC_DNS_SERVER " == " true" ]]; then
1719
+ primary_ns=" $primary_ns $PUBLIC_DNS_SERVER "
1720
+ fi
1721
+
1722
+ debug set primary_ns=" $primary_ns "
1683
1723
return
1684
1724
fi
1685
1725
fi
0 commit comments