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

request-cert doesn't handle JSON responses #26

Open
Spindel opened this issue Jun 17, 2015 · 3 comments
Open

request-cert doesn't handle JSON responses #26

Spindel opened this issue Jun 17, 2015 · 3 comments
Assignees

Comments

@Spindel
Copy link
Member

Spindel commented Jun 17, 2015

We recently enabled JSON responses for the web service, however request-cert still lives in a world where it parses html.

A fix will be upcoming.

@Spindel Spindel self-assigned this Jun 17, 2015
Spindel added a commit that referenced this issue Jun 17, 2015
We have moved over to using JSON formatted error messages, rather than
html templates.

This fixes issue #26
@Spindel
Copy link
Member Author

Spindel commented Jun 17, 2015

for review @niligulmohar

Spindel added a commit that referenced this issue Jun 29, 2015
We have moved over to using JSON formatted error messages, rather than
html templates.

This fixes issue #26
@ooduor
Copy link

ooduor commented Jul 21, 2015

@Spindel @niligulmohar I randomly get this error. Could it be related to this issue?

(modio)[anthony@archilles request-certificate]$ ./request-cert caramel.modio.se '9772851a-b218-4a43-8d92-cdd204acec9e'
Key file 9772851a-b218-4a43-8d92-cdd204acec9e.key is valid; using it
Certificate signing request file 9772851a-b218-4a43-8d92-cdd204acec9e.csr is valid; using it
Starting new HTTPS connection (1): caramel.modio.se
"GET /d20c32c9c0d787c009629e7cecfc4e03438bca425edce3b4484fff008e4fd4ec HTTP/1.1" 504 182
Traceback (most recent call last):
  File "/opt/mapylons/secureapp/request-certificate/caramelrequest/certificaterequest.py", line 187, in parse
    result = response.json()
  File "/home/anthony/.virtualenvs/modio/lib/python3.4/site-packages/requests-2.4.3-py3.4.egg/requests/models.py", line 793, in json
    return json.loads(self.text, **kwargs)
  File "/usr/lib64/python3.4/json/__init__.py", line 318, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python3.4/json/decoder.py", line 343, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python3.4/json/decoder.py", line 361, in raw_decode
    raise ValueError(errmsg("Expecting value", s, err.value)) from None
ValueError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./request-cert", line 5, in <module>
    main()
  File "/opt/mapylons/secureapp/request-certificate/caramelrequest/certificaterequest.py", line 226, in main
    CertificateRequest(server=server, client_id=client_id).perform()
  File "/opt/mapylons/secureapp/request-certificate/caramelrequest/certificaterequest.py", line 36, in perform
    self.request_cert_from_server()
  File "/opt/mapylons/secureapp/request-certificate/caramelrequest/certificaterequest.py", line 171, in request_cert_from_server
    .format(parse(response)))
  File "/opt/mapylons/secureapp/request-certificate/caramelrequest/certificaterequest.py", line 189, in parse
    result = parse_html(response)
  File "/opt/mapylons/secureapp/request-certificate/caramelrequest/certificaterequest.py", line 195, in parse_html
    for e in ET.fromstring(response.text).iterfind('body//'))
  File "/usr/lib64/python3.4/xml/etree/ElementTree.py", line 1325, in XML
    parser.feed(text)
xml.etree.ElementTree.ParseError: mismatched tag: line 6, column 2

@Spindel
Copy link
Member Author

Spindel commented Jul 21, 2015

Could be, the first dump is the json.decode() failing, the second one is a complaint about mismatched tag in the second part.

Best would be to have a printout of what it's actually returned (Raw) before so we know why it's failing.

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

No branches or pull requests

2 participants