letsencrypt-cloudflare-hook icon indicating copy to clipboard operation
letsencrypt-cloudflare-hook copied to clipboard

Hook doent work!

Open vaminakov opened this issue 6 years ago • 4 comments
trafficstars

Hello! After some changes on cloudflare hook stopped working. Not it have issue:

+ 2 pending challenge(s)
 + Deploying challenge tokens...
 + CloudFlare hook executing: deploy_challenge
Traceback (most recent call last):
  File "/etc/dehydrated/hooks/letsencrypt-cloudflare-hook.py", line 206, in <module>
    main(sys.argv[1:])
  File "/etc/dehydrated/hooks/letsencrypt-cloudflare-hook.py", line 203, in main
    ops[argv[0]](argv[1:])
  File "/etc/dehydrated/hooks/letsencrypt-cloudflare-hook.py", line 167, in create_all_txt_records
    create_txt_record(args[i:i+X])
  File "/etc/dehydrated/hooks/letsencrypt-cloudflare-hook.py", line 105, in create_txt_record
    zone_id = _get_zone_id(domain)
  File "/etc/dehydrated/hooks/letsencrypt-cloudflare-hook.py", line 83, in _get_zone_id
    return r.json()['result'][0]['id']
IndexError: list index out of range

vaminakov avatar Apr 15 '19 10:04 vaminakov

It seems that CloudFlare api changed answer of json request:

{'result': [], 'result_info': {'page': 1, 'per_page': 20, 'total_pages': 0, 'count': 0, 'total_count': 0}, 'success': True, 'errors': [], 'messages': []}

so it haven't ID.

vaminakov avatar Apr 17 '19 09:04 vaminakov

hey, for me, the problem was the function get_tld --> get top level domain, somehow it returned only as suggested the top level domain which ended up beeing ".com, .de and so on..." Somehow clear that this couldnt work, how did it ever thou? what fixed it was to exchange in "hook.py": get_tld with get_fld in line:

 from tld import get_fld

and the call in function:

def _get_zone_id(domain):
    fld = get_fld('http://' + domain)
    url = "https://api.cloudflare.com/client/v4/zones?name={0}".format(fld)
    r = requests.get(url, headers=CF_HEADERS)
    r.raise_for_status()
    return r.json()['result'][0]['id']

this worked for me.

D-Workz avatar May 13 '19 16:05 D-Workz

Since this repo is abandoned by its owner, there is a new maintained fork that also addresses dependency issues including vulnerabilities in the dependencies: https://github.com/SeattleDevs/letsencrypt-cloudflare-hook . That repo has the fix which @D-Workz mentioned. Feel free to open an issue in that repo if you find a problem.

YasharF avatar May 18 '19 16:05 YasharF

cool thanks, for the team work

D-Workz avatar May 22 '19 08:05 D-Workz