Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved determination of root domain for the Variomedia DNS API #3244

Closed
wants to merge 4 commits into from

Conversation

peterkelm
Copy link
Contributor

Rewrite of _get_root() to address an issue with the handling of subdomains in the /domains call of the Variomedia DNS API. See #2564.

fulldomain=$1
i=1
domain=$1
i=2
Copy link
Member

@Neilpang Neilpang Nov 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the value of "i" should be beginning from 1, not 2.

In dns alias mode, the fulldomain can be no _acme-challenge prefix

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's been tested:

  • successfully with i=2
  • unsuccessfully with i=1

@Neilpang Neilpang deleted the branch acmesh-official:dev January 19, 2022 12:57
@Neilpang Neilpang closed this Jan 19, 2022
@Neilpang Neilpang reopened this Jan 19, 2022
@fraenki
Copy link
Contributor

fraenki commented Feb 20, 2022

@peterkelm Using this patch, I can confirm that it fixes the creation of TXT records with acme.sh. However, in my case it failed to remove the TXT records afterwards. Some unusual cURL output is shown and then a failure is reported:

[Mon Feb 21 00:21:46 CET 2022] Here is the curl dump log:
[Mon Feb 21 00:21:46 CET 2022] == Info:   Trying 81.28.224.32:443...
== Info: Connected to api.variomedia.de (81.28.224.32) port 443 (#0)
== Info: ALPN, offering h2
== Info: ALPN, offering http/1.1
== Info:  CAfile: /usr/local/etc/ssl/cert.pem
== Info:  CApath: none
=> Send SSL data, 5 bytes (0x5)
...
[Mon Feb 21 00:21:46 CET 2022] ret='3'
[Mon Feb 21 00:21:46 CET 2022] Error dns-records?filter[domain]=example.com
[Mon Feb 21 00:21:46 CET 2022] Error
[Mon Feb 21 00:21:46 CET 2022] Error removing txt for domain:_acme-challenge.example.com

@TobiasGrave
Copy link

@peterkelm Using this patch, I can confirm that it fixes the creation of TXT records with acme.sh. However, in my case it failed to remove the TXT records afterwards. Some unusual cURL output is shown and then a failure is reported:

[Mon Feb 21 00:21:46 CET 2022] Here is the curl dump log:
[Mon Feb 21 00:21:46 CET 2022] == Info:   Trying 81.28.224.32:443...
== Info: Connected to api.variomedia.de (81.28.224.32) port 443 (#0)
== Info: ALPN, offering h2
== Info: ALPN, offering http/1.1
== Info:  CAfile: /usr/local/etc/ssl/cert.pem
== Info:  CApath: none
=> Send SSL data, 5 bytes (0x5)
...
[Mon Feb 21 00:21:46 CET 2022] ret='3'
[Mon Feb 21 00:21:46 CET 2022] Error dns-records?filter[domain]=example.com
[Mon Feb 21 00:21:46 CET 2022] Error
[Mon Feb 21 00:21:46 CET 2022] Error removing txt for domain:_acme-challenge.example.com

The removal of the the TXT record fails when its content starts with a -.

This problem is caused by grep "$txtvalue" in the following line:
record_id="$(echo "$response" | cut -d '[' -f2 | cut -d']' -f1 | sed 's/},[ \t]*{/\},§\{/g' | tr § '\n' | grep "$_sub_domain" | grep "$txtvalue" | sed 's/^{//;s/}[,]?$//' | tr , '\n' | tr -d '\"' | grep ^id | cut -d : -f2 | tr -d ' ')"

This is due to grep interpreting everything starting with a - as an option and not as a search term.
In order to fix this, the option -- has to be added before the search term (https://www.gnu.org/software/grep/manual/grep.html#index-_002d_002d):
_record_id="$(echo "$response" | cut -d '[' -f2 | cut -d']' -f1 | sed 's/},[ \t]*{/\},§\{/g' | tr § '\n' | grep "$_sub_domain" | grep -- "$txtvalue" | sed 's/^{//;s/}[,]?$//' | tr , '\n' | tr -d '\"' | grep ^id | cut -d : -f2 | tr -d ' ')"

@TobiasGrave TobiasGrave mentioned this pull request Aug 30, 2023
@TobiasGrave TobiasGrave mentioned this pull request Sep 7, 2023
@Neilpang Neilpang closed this Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants