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

Update dns api to support v2 wildcard cert #1261

Open
6 of 11 tasks
Neilpang opened this issue Feb 13, 2018 · 80 comments
Open
6 of 11 tasks

Update dns api to support v2 wildcard cert #1261

Neilpang opened this issue Feb 13, 2018 · 80 comments
Labels

Comments

@Neilpang
Copy link
Member

Neilpang commented Feb 13, 2018

To support v2 wildcard cert, we need to add 2 txt records for the same domain.
for example:

_acme-challenge.example.com   TXT   "this is txt value 1"
_acme-challenge.example.com   TXT   "this is txt value 2"

In many dns api hooks, in the dns_xx_add() function, they try to UPDATE the existing txt record, instead of ADD a new record.
This was a good practice for ACME v1, but it's not good in ACME v2.

In ACME v2, we just need to add new txt record all the time in the dns_xx_add() function,
And in the the dns_xx_rm() function, we must delete the txt record according to the specified txt value.

Test example:

acme.sh  --issue --test  -d example.com  -d *.example.com

Please make sure this works, and the 2 txt records are removed after the cert is issued.

See my changes:

ea25492#diff-51fe23dd1a90a481487dbca5b9c3ae24

72f54ca#diff-d48ca70b90232acffb2b5b9d1ec2938a

584fb29#diff-f272833bc0ccf326ea343539e829f1d3

  • dns_ad
  • dns_ali
  • dns_azure
  • dns_cloudns
  • dns_dnsimple
  • dns_freedns
  • dns_gandi_livedns
  • dns_me
  • dns_nsone
  • dns_pdns
  • dns_unoeuro
@Neilpang Neilpang added the bug label Feb 13, 2018
@Neilpang
Copy link
Member Author

@wpk- Please update the rm function of dns_ad hook.

@Neilpang
Copy link
Member Author

@baiyangliu please support the rm function for dns_ali hook.

@Neilpang
Copy link
Member Author

@martgras please make sure dns_azure hook works in this way.

@Neilpang
Copy link
Member Author

@boyanpeychev please update dns_cloudns hook

@boyanpeychev
Copy link
Contributor

boyanpeychev commented Feb 14, 2018

@Neilpang please accept this pull request and I will proceed with the wildcard implementation:
#1094

@Neilpang
Copy link
Member Author

@boyanpeychev accepted, please go ahead.

@Neilpang
Copy link
Member Author

@pho3nixf1re please update dns_dnsimple hook

@Neilpang
Copy link
Member Author

@dkerr64 please update dns_freedns.sh

@Neilpang
Copy link
Member Author

@fcrozat please update dns_gandi_livedns.sh

@Neilpang
Copy link
Member Author

@justmwa please update dns_me.sh

@Neilpang
Copy link
Member Author

@justmwa please also update dns_nsone.sh

@Neilpang
Copy link
Member Author

@magna-z please update dns_pdns.sh

@Neilpang
Copy link
Member Author

@Aarup please update dns_unoeuro.sh

@drybalkadk
Copy link

aws work. Thanks a lot

@martgras
Copy link
Contributor

martgras commented Feb 14, 2018 via email

@Neilpang
Copy link
Member Author

@martgras thank you.

@boyanpeychev
Copy link
Contributor

no changes needed for dns_cloudns.sh

@Neilpang
Copy link
Member Author

@boyanpeychev There is an updating logic in the dns_cloudns_add() function.
Are you sure no changes are needed there?

Please make sure this case is passing:

acme.sh  --issue --test  -d example.com  -d *.example.com

@justmwa
Copy link
Contributor

justmwa commented Feb 17, 2018

Works as is because there's only one TXT sent from what I can see in logs. And since LE accepts it, they changed their mind about the double TXT record ?

@justmwa
Copy link
Contributor

justmwa commented Feb 17, 2018

Message to those who think it works "as is", try with a subdomain ;) (unless it's not officially supported?)
i.e foo.example.com. Actually it's only an issue with one API so far, need to dig further.

@Neilpang
Copy link
Member Author

@justmwa no, never.
please use a new domain to test.

acme.sh --issue  -d  sub.domain.com  -d *.sub.domain.com

@martgras
Copy link
Contributor

Fixed the Azure hook only 1 DNS record was added: #1287

@boyanpeychev
Copy link
Contributor

@Neilpang, yes, it is tested with completely new domain and sub-domain for Let's Encrypt and it works both for the root domain name and with a sub-domain. The records are added successfully.

However, I do see one problem not related to the cloudns.net api - sometimes the given token is not accepted by Let's Encrypt, even it is resolved absolutely properly. Here is example log:
test.log

The TXT records requested to be added is with token: GUFN5HSXlmothHwsZWbCZW-SfgCaQYCTTB874fZ6Ijw
The same token is found by Let's Encrypt, but reported as invalid. Please check you too.

@martgras
Copy link
Contributor

martgras commented Feb 19, 2018

I don't understand the cloudns api well enough but I suspect you run into the the same problem I had with Azure in #1287
Instead of creating 2 txt entries my code was first creating
_acme-challenge.test.cloudns.biz. 10 IN TXT "DyLeOblvCb1I9DqZ2BlB0fdQYsA3or4WVdZN139KaHg" and then the second call to dns_azure_add changed this txt record to
_acme-challenge.test.cloudns.biz. 10 IN TXT "GUFN5HSXlmothHwsZWbCZW-SfgCaQYCTTB874fZ6Ijw"

therefore the validation failed
Make sure you really create 2 entries instead of updating the existing one

Basically I have to use a Json body like this for the Azure DNS REST API call

{
    "properties": {
        "TTL": 10,
        "TXTRecords": [
            {   "value": ["DyLeOblvCb1I9DqZ2BlB0fdQYsA3or4WVdZN139KaHg"] },
            {   "value": ["GUFN5HSXlmothHwsZWbCZW-SfgCaQYCTTB874fZ6Ijw"]  }
        ]
    }
}

you should see something like this when checking with dig

dig -t txt _acme-challenge.test.cloudns.biz
_acme-challenge.test.cloudns.biz. 10 IN TXT "DyLeOblvCb1I9DqZ2BlB0fdQYsA3or4WVdZN139KaHg"
_acme-challenge.test.cloudns.biz. 10 IN TXT "GUFN5HSXlmothHwsZWbCZW-SfgCaQYCTTB874fZ6Ijw"

boyanpeychev added a commit to ClouDNS/acme.sh that referenced this issue Feb 19, 2018
@boyanpeychev
Copy link
Contributor

Thanks for the hint. Fixed. Pull request submitted.

@Neilpang
Copy link
Member Author

@boyanpeychev It's not enough yet.
In the rm() function, you must remove the record by the exact txt value.
In the rm() function:

record_id=$(_dns_cloudns_get_record_id "$zone" "$host")

But the _dns_cloudns_get_record_id() function seems not considering the txt value.

@martgras
Copy link
Contributor

@Neilpang the same is true for Azure but why does it matter?

first call to dns_azure_rm :
DELETE https://management.azure.com/subscriptions/../dnszones/example.com/TXT/_acme-challenge.somesub1.test?api-version=2017-09-01
http response code 200

second call:
DELETE https://management.azure.com/subscriptions/../dnszones/example.com/TXT/_acme-challenge.somesub1.test?api-version=2017-09-01
http response code 204

so yes the first call removes the record already but I don't see the problem with this approach

@Neilpang
Copy link
Member Author

@martgras Yes, it doesn't matter if it's only you that use the domain to verify the cert.
If there are multiple people validating the same domain, you may remove the txt domain from others.
Especially we will soon merge the support for dns alias mode: https://github.com/Neilpang/acme.sh/wiki/DNS-alias-mode

So, it's strongly recommended that you only remove the txt record added by you.

@saymonz
Copy link

saymonz commented Oct 9, 2018

mhhh ok. So the integration with GandiLiveDNS still needs work.
Thanks @zloster for your feedback. :-)

Using Gandi for a domain.tld & *.domain.tld cert. It works, but I have to launch acme.sh two times in "quick" burst : it fails first, and pass on second time. Same with renewal cron job.

@tristanbes
Copy link

same for us @saymonz using GandLiveDNS, it randomly fails, running it a second time "fixes" it.

@dkerr64
Copy link
Contributor

dkerr64 commented Oct 9, 2018

I ran into a similar problem with FreeDNS and had to code around it. Not sure if you are running into exactly the same reasons for the "required twice" but see comment in the code for dns_freedns.sh around line 59... https://github.com/Neilpang/acme.sh/blob/c31db83b26afa1468aa00aafd63c64f2c410811d/dnsapi/dns_freedns.sh#L59-L63

David

drott added a commit to drott/acme.sh that referenced this issue Dec 28, 2018
Gandi supports setting multiple entries by setting multiple array items
for the rrset_values field in their API. Modify the dns_gandi_livedns.sh
script so that it checks for existing entries, appends new ones if
needed, and removes existing ones individually. This enabled wildcard
certificate support on Gandi.

Fixes the dns_gandi_livedns part of acmesh-official#1261.

Tested for creating a multidomain, multiple wild-card certificate on
Gandi and using a test script executing only the dns_gandi_livedns_add
and dns_gandi_livedns_rm functions.
drott added a commit to drott/acme.sh that referenced this issue Dec 28, 2018
Gandi supports setting multiple entries by setting multiple array items
for the rrset_values field in their API. Modify the dns_gandi_livedns.sh
script so that it checks for existing entries, appends new ones if
needed, and removes existing ones individually. This enabled wildcard
certificate support on Gandi.

Fixes the dns_gandi_livedns part of acmesh-official#1261.

Tested for creating a multidomain, multiple wild-card certificate on
Gandi and using a test script executing only the dns_gandi_livedns_add
and dns_gandi_livedns_rm functions.
drott added a commit to drott/acme.sh that referenced this issue Dec 28, 2018
Gandi supports setting multiple entries by setting multiple array items
for the rrset_values field in their API. Modify the dns_gandi_livedns.sh
script so that it checks for existing entries, appends new ones if
needed, and removes existing ones individually. This enabled wildcard
certificate support on Gandi.

Fixes the dns_gandi_livedns part of acmesh-official#1261.

Tested for creating a multidomain, multiple wild-card certificate on
Gandi and using a test script executing only the dns_gandi_livedns_add
and dns_gandi_livedns_rm functions.
drott added a commit to drott/acme.sh that referenced this issue Dec 28, 2018
Gandi supports setting multiple entries by setting multiple array items
for the rrset_values field in their API. Modify the dns_gandi_livedns.sh
script so that it checks for existing entries, appends new ones if
needed, and removes existing ones individually. This enabled wildcard
certificate support on Gandi.

Fixes the dns_gandi_livedns part of acmesh-official#1261.

Tested for creating a multidomain, multiple wild-card certificate on
Gandi and using a test script executing only the dns_gandi_livedns_add
and dns_gandi_livedns_rm functions.
drott added a commit to drott/acme.sh that referenced this issue Dec 29, 2018
Gandi supports setting multiple entries by setting multiple array items
for the rrset_values field in their API. Modify the dns_gandi_livedns.sh
script so that it checks for existing entries, appends new ones if
needed, and removes existing ones individually. This enabled wildcard
certificate support on Gandi.

Fixes the dns_gandi_livedns part of acmesh-official#1261.

Tested for creating a multidomain, multiple wild-card certificate on
Gandi and using a test script executing only the dns_gandi_livedns_add
and dns_gandi_livedns_rm functions.
@drott
Copy link

drott commented Jan 4, 2019

  • dns_gandi_livedns

after the merge in 83a0407.

@myelsukov
Copy link

Hi there!

I am using https://dyn.com/ They support nsupdate method but they require both TXT records to be added in a single update. Basically, they do remove all matching records prior to adding the new ones.
I hacked acme.sh and dnsapi/dns_nsupdate.sh so they work for me, but the hack is pretty ugly, so I am ashamed to post it as a PR :)

In a nutshell: In the acme.sh.issue() I check if the API supports .*_multi_add command.
If the command is supported then in the for ventry in $ventries loop I am collecting an array of values instead of sending individual requests. Then I execute one API call after the loop and pass to the API the collected domain+txt pairs.

I wonder if acme gurus could properly implement the feature allowing adding several TXT records in one update session?

@jahlives
Copy link

jahlives commented May 7, 2019

I'm trying to get a wildcard certificate using dns_pdns
Logs tell me that two records are added

[Die Mai 7 09:41:24 CEST 2019] Found domain api file: /root/.acme.sh/dnsapi/dns_pdns.sh
[Die Mai 7 09:41:24 CEST 2019] Adding record
[Die Mai 7 09:41:25 CEST 2019] Found domain api file: /root/.acme.sh/dnsapi/dns_pdns.sh
[Die Mai 7 09:41:25 CEST 2019] Adding record

But as the dns server only shows one value I assume that dns_pdns is not ready for v2 wildcard certs. First post in this report shows dns_pdns not as fixed yet.
Does anyone have a working dns_pdns for v2 wildcard certificates?

output of acme.sh sez that the token is "not valid yet" and acme.sh waits for 10s to repeat the check and fails again (in a loop)

[Die Mai 7 09:53:01 CEST 2019] Checking REDACTED.ch for _acme-challenge.REDACTED.ch
[Die Mai 7 09:53:01 CEST 2019] Not valid yet, let's wait 10 seconds and check next one.

But according to the pdns server at least one record for _acme-challenge.REDACTED.ch does exist

@jahlives
Copy link

jahlives commented May 7, 2019

did some more diging in dns_pdns code. It seems to me that the script cannot get the list of already existing challenges as the pdns api uri only gives back a "500 Internal server error"

curl -X GET -H 'X-API-Key: MY_API_KEY' http://127.0.0.1:8081/api/v1/servers/localhost/zones/mydomain.tld

Any pdns user here who can verify if that URI still works or not? I'm using pdns server 4.1.8
It's the only query that does not work so far. All others seem to be fine

@jahlives
Copy link

jahlives commented May 7, 2019

dns_pdns is finally working fine. Was never a acme problem but one with the pdns server. We use mysql backend for pdns and our frontend application inserts TXT records like this
v=spf1 mx -all
pdns server then packs the string into " and " before returning it in queries to clients. But the API interface does not perform this step and then sees incorrect TXT records in the zone and therefore the API endpoint returns with the server error. Which leads acme.sh to the assumption that no other challenge exists in the zone.
Long story short: if using pdns with mysql backend one has to ensure that TXT records are inserted like this
"v=spf1 mx -all"
then pdns api is happy

@Neilpang
from my point of view dns_pdns works correctly with LE v2 wildcard certificates.

@Neilpang
Copy link
Member Author

Neilpang commented May 8, 2019

@jahlives Thanks.

@Neilpang Neilpang unpinned this issue Jul 2, 2019
@phedoreanu
Copy link
Contributor

  • dns_1984hosting

after merging #2852.

lbrocke added a commit to lbrocke/acme.sh that referenced this issue Dec 24, 2020
The IONOS DNS API is in beta state, please read [1] on how to get
started.

PLEASE NOTE: The v2 wildcard certification creation [2] is not yet
supported as the IONOS API doesn't allow the creation of multiple TXT
records with the same domain name.

[1] https://beta.developer.hosting.ionos.de/docs/getstarted
[2] acmesh-official#1261
mjbnz pushed a commit to mjbnz/acme.sh that referenced this issue Apr 8, 2021
The IONOS DNS API is in beta state, please read [1] on how to get
started.

PLEASE NOTE: The v2 wildcard certification creation [2] is not yet
supported as the IONOS API doesn't allow the creation of multiple TXT
records with the same domain name.

[1] https://beta.developer.hosting.ionos.de/docs/getstarted
[2] acmesh-official#1261
Sp1l pushed a commit to Sp1l/acme.sh that referenced this issue Aug 10, 2021
The IONOS DNS API is in beta state, please read [1] on how to get
started.

PLEASE NOTE: The v2 wildcard certification creation [2] is not yet
supported as the IONOS API doesn't allow the creation of multiple TXT
records with the same domain name.

[1] https://beta.developer.hosting.ionos.de/docs/getstarted
[2] acmesh-official#1261
@Djelibeybi
Copy link
Contributor

  • dns_oci

@GreenUkr
Copy link

GreenUkr commented Mar 6, 2022

The same issue (acme.sh --issue --test -d example.com -d *.example.com got error trying to create existent value istead of add key to it) with dns_nsone
Correct it if possible, please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests