Closed sylvainOL closed 1 year ago
Hello,
If I create a PR to fix the problem, can you test it?
can you try PR #1982 ?
I'll make a test, yes :)
It doesn't seem to work :(
Here's what I did (I'm not sure it's the right thing...):
here's the result:
$ lego --version
lego version 52f43de48580aeb5769e7073beee4f24277be499 linux/amd64
$ lego --accept-tos --email <redacted> --dns pdns --server https://acme-staging-v02.api.letsencrypt.org/directory --domains test.gating.tld --dns.disable-cp run --no-bundle
2023/08/03 09:35:18 No key found for account <redacted>. Generating a P256 key.
2023/08/03 09:35:18 Saved key to /builds/oln/nif/cd/tools/lego-vault/.lego/accounts/acme-staging-v02.api.letsencrypt.org/<redacted>/keys/<redacted>.key
2023/08/03 09:35:19 [INFO] acme: Registering account for <redacted>
!!!! HEADS UP !!!!
Your account credentials have been saved in your Let's Encrypt
configuration directory at "/builds/oln/nif/cd/tools/lego-vault/.lego/accounts".
You should make a secure backup of this folder now. This
configuration directory will also contain certificates and
private keys obtained from Let's Encrypt so making regular
backups of this folder is ideal.
2023/08/03 09:35:19 [INFO] [test.gating.] acme: Obtaining SAN certificate
2023/08/03 09:35:20 [INFO] [test.gating.tld] AuthURL: https://acme-staging-v02.api.letsencrypt.org/acme/authz-v3/7577377814
2023/08/03 09:35:20 [INFO] [test.gating.tld] acme: Could not find solver for: tls-alpn-01
2023/08/03 09:35:20 [INFO] [test.gating.tld] acme: Could not find solver for: http-01
2023/08/03 09:35:20 [INFO] [test.gating.tld] acme: use dns-01 solver
2023/08/03 09:35:20 [INFO] [test.gating.tld] acme: Preparing to solve DNS-01
2023/08/03 09:35:21 [INFO] [test.gating.tld] acme: Cleaning DNS-01 challenge
2023/08/03 09:35:22 [WARN] [test.gating.tld] acme: cleaning up failed: unexpected status code: [request: PUT https://pdns.server/api/v1/servers/localhost/zones/tld./notify] [status code: 400] body: {"msg":"Request is not json"}
2023/08/03 09:35:22 [INFO] Deactivating auth: https://acme-staging-v02.api.letsencrypt.org/acme/authz-v3/7577377814
2023/08/03 09:35:22 Could not obtain certificates:
error: one or more domains had a problem:
[test.gating.tld] [test.gating.tld] acme: error presenting token: unexpected status code: [request: PUT https://pdns.server/api/v1/servers/localhost/zones/tld./notify] [status code: 400] body: {"msg":"Request is not json"}
I'm actually a bit stupid: I can request PDNS from my PC so I've build and test directly the PR and doesn't work either (same version as the one gave previously -- 52f43de48580aeb5769e7073beee4f24277be499
-- and same result)
I don't understand, the doc is not really clear but I think I followed the https://doc.powerdns.com/md/httpapi/api_spec/#url-apiv1serversserver95idzoneszone95idnotify
I'll make some tests after lunch (I've got the same behavior with curl...)
thanks!
Ok I found the thing, you will "laugh" (or not ^_^)
Even if the body is nil, we must set Content-Type
header to application/json
as (almost) stated here: https://doc.powerdns.com/md/httpapi/api_spec/#data-format (it's actually false, you don't need to set Accept
header but you do need Content
one according to my tests...)
Previously (in <=4.11
), the way to set the header was:
if method != http.MethodGet && method != http.MethodDelete {
req.Header.Set("Content-Type", "application/json")
}
Now, it's:
if payload != nil {
req.Header.Set("Content-Type", "application/json")
}
so I guess we should go back to previous version :)
I can make a PR or leave it to you as you prefer!
I've made a PR but you can make one if you prefer!
thanks again
All I had to do was update my PR: I asked you to test it to be able to update it if needed :wink:
no problem, I just wanted to annoy you the least possible :)
There is no problem, I will keep your PR.
Welcome
What did you expect to see?
successful use of lego like (the one I've got with lego
4.11
:What did you see instead?
I've got
{"msg":"Request is not json"}
when requesting pdns API (I've set hereLEGO_DEBUG_CLIENT_VERBOSE_ERROR
env var toTRUE
in order to see a bit more:How do you use lego?
Binary
Reproduction steps
Version of lego
Logs
Go environment (if applicable)
N/A