kappataumu / letsencrypt-cloudflare-hook

Use CloudFlare with dehydrated (formerly letsencrypt.sh) and DNS challenges
MIT License
273 stars 107 forks source link

HTTPError: 400 Client Error: Bad Request for url: https://api.cloudflare.com/client/v4/zones #57

Open uzzal2k5 opened 5 years ago

uzzal2k5 commented 5 years ago

I'm configuring dehydrated with CloudFlare but getting following error. I would be very happy if anyone can quick help.

ENV- Python-3.5

 + CloudFlare hook executing: deploy_challenge

Traceback (most recent call last):
  File "/opt/dehydrated/hooks/cloudflare/hook.py", line 206, in <module>
    main(sys.argv[1:])
  File "/opt/dehydrated/hooks/cloudflare/hook.py", line 203, in main
    ops[argv[0]](argv[1:])
  File "/opt/dehydrated/hooks/cloudflare/hook.py", line 167, in create_all_txt_records
    create_txt_record(args[i:i+X])
  File "/opt/dehydrated/hooks/cloudflare/hook.py", line 105, in create_txt_record
    zone_id = _get_zone_id(domain)
  File "/opt/dehydrated/hooks/cloudflare/hook.py", line 82, in _get_zone_id
    r.raise_for_status()
  File "/usr/lib/python3/dist-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.cloudflare.com/client/v4/zones?name=space
JohnVillalovos commented 4 years ago

The fix for this is to do this.

Change https://github.com/kappataumu/letsencrypt-cloudflare-hook/blob/master/hook.py#L21

To: import tld

And change: https://github.com/kappataumu/letsencrypt-cloudflare-hook/blob/master/hook.py#L79

To: tld = tld.get_fld('http://' + domain)

YasharF commented 4 years ago

FYI: this repo is abandoned by its owner, but there is a maintained fork that does not have the mentioned issue:: https://github.com/SeattleDevs/letsencrypt-cloudflare-hook . Feel free to open an issue in that repo if you find a problem.

moose999 commented 4 years ago

I have this same problem with https://github.com/walcony/letsencrypt-cloudflare-hook, and issues are not enabled on that repo!

YasharF commented 4 years ago

I enabled Github Issues on that repo, can you create an issue there? https://github.com/SeattleDevs/letsencrypt-cloudflare-hook/issues/new/choose

prashnts commented 4 years ago

Thanks @YasharF for that! It is working fine for me without any changes (just swapped old version with yours).