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

Check HTTP response codes, and parse RFC7807 problem reports. #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

wiml
Copy link
Contributor

@wiml wiml commented Jan 13, 2017

Currently, if something goes wrong and an HTTP request fails or the ACME server rejects a request, the status code will be ignored and the response will be parsed as JSON, BER, or whatever. This patch adds minimal checking for HTTP errors, and in the case of RFC7807-formatted error responses, parses the problem report into a more convenient erlang term representation.

rebar3 ct passes. You can test the error-handling and -parsing functionality by, e.g., removing the rate-limit overrides in boulder's test/rate-limit-policies.yml and rerunning the common tests against that boulder instance.

@gbour
Copy link
Owner

gbour commented Jan 13, 2017

thanks @wiml. I will have a look this weekend

@gbour
Copy link
Owner

gbour commented Jan 18, 2017

Hi @wiml. First, thank you for your PR, it is very interesting.

But your changes triggers an exception, when setting an invalid domain name:
current master branch:

> letsencrypt:make_cert(<<"foo">>, #{async => false}).
{error,<<"DNS name does not have enough labels">>}

with your patch:

** Reason for termination = 
** {{badmatch,{problem,{acme,malformed},
                       none,
                       [{status,400},
                        {detail,<<"DNS name does not have enough labels">>},
                        {status,400}]}},
    [{letsencrypt_api,new_authz,6,
                      [{file,"/home/gbour/devel/letsencrypt-erlang-wiml/_build/default/lib/letsencrypt/src/lets
encrypt_api.erl"},
                       {line,83}]},

in fact, it may happen everywhere post() is called and matched with {ok, Nonce, Body}

@wiml
Copy link
Contributor Author

wiml commented Jul 30, 2017

Ah, I see. In some other code paths the badmatch was at least a better error message than the cryptic error from the ASN.1 parser when trying to parse text as if it were DER, but in that spot it's a step backwards. I'll update this to pass the error along properly in the situations where that's possible.

return type of post/4 is more uniform. More precise type specifications.
@wiml
Copy link
Contributor Author

wiml commented Jan 31, 2018

FWIW, the errored travis-ci check, above (build #215), looks like it was due to a problem with travis, not with this patch specifically.

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

Successfully merging this pull request may close these issues.

2 participants