Git Product home page Git Product logo

Comments (2)

sdgathman avatar sdgathman commented on June 2, 2024

So, problem is reusing resp_data reference means that when there is an error parsing the string, it is still a string and not a dict. So running with this patch (purposefully ot fixing whatever the apache config error is until the acme-tiny error handling is fixed):

@@ -36,10 +36,11 @@
         except IOError as e:
             resp_data = e.read().decode("utf8") if hasattr(e, "read") else str(e)
             code, headers = getattr(e, "code", None), {}
+        resp_raw = resp_data
         try:
-            resp_data = json.loads(resp_data) # try to parse json results
+            resp_data = json.loads(resp_raw) # try to parse json results
         except ValueError:
-            pass # ignore json parsing errors
+            raise ValueError("{0}:\nUrl: {1}\nData: {2}\nResponse Code: {3}\nResponse: {4}".format(err_msg, url, data, code, '"%s"'%resp_raw))
         if depth < 100 and code == 400 and resp_data['type'] == "urn:ietf:params:acme:error:badNonce":
             raise IndexError(resp_data) # allow 100 retrys for bad nonces
         if code not in [200, 201, 204]:

I discover that code is 204 and resp_raw is empty from LE:

acme-tiny[1101418]:   File "/usr/sbin/acme_tiny", line 43, in _do_request
acme-tiny[1101418]:     raise ValueError("{0}:\nUrl: {1}\nData: {2}\nResponse Code: {3}\nResponse: {4}".format(err_msg, url, data, code, '"%s"'%resp_raw))
acme-tiny[1101418]: ValueError: Error:
acme-tiny[1101418]: Url: https://acme-v02.api.letsencrypt.org/acme/new-nonce
acme-tiny[1101418]: Data: None
acme-tiny[1101418]: Response Code: 204
acme-tiny[1101418]: Response: ""

from acme-tiny.

sdgathman avatar sdgathman commented on June 2, 2024

Ok, this patch is minimal code change and makes the error much clearer:

@@ -39,7 +39,7 @@
         try:
             resp_data = json.loads(resp_data) # try to parse json results
         except ValueError:
-            pass # ignore json parsing errors
+            resp_data = {'type':None, 'raw': resp_data}
         if depth < 100 and code == 400 and resp_data['type'] == "urn:ietf:params:acme:error:badNonce":
             raise IndexError(resp_data) # allow 100 retrys for bad nonces
         if code not in [200, 201, 204]:

And the resulting error is:

acme-tiny[1111183]: ValueError: Wrote file to /var/www/challenges/0eG_qrrSE_OpkH5114hcl8auxZPFqtRxX72HvXKyjaQ, but couldn't download http://melissa.gathman.org/.well-known/acme-challenge/0eG_qrrSE_OpkH5114hcl8auxZPFqtRxX72HvXKyjaQ: Error:
acme-tiny[1111183]: Url: http://melissa.gathman.org/.well-known/acme-challenge/0eG_qrrSE_OpkH5114hcl8auxZPFqtRxX72HvXKyjaQ
acme-tiny[1111183]: Data: None
acme-tiny[1111183]: Response Code: 400
acme-tiny[1111183]: Response: {'type': None, 'raw': '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n<html><head>\n<title>400 Bad Request</title>\n</head><body>\n<h1>Bad Request</h1>\n<p>Your browser sent a request that this server could not understand.<br />\nReason: You\'re speaking plain HTTP to an SSL-enabled server port.<br />\n Instead use the HTTPS scheme to access this URL, please.<br />\n</p>\n</body></html>\n'}

from acme-tiny.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.