Skip to content

Authenticator Cleanup - #162

Merged
jdkasten merged 21 commits into
masterfrom
dvsni_cleanup
Jan 15, 2015
Merged

jdkasten merged 21 commits into
masterfrom
dvsni_cleanup

Conversation

@jdkasten

Copy link
Copy Markdown
Contributor

It was necessary to make a better general API for IAuthenticators. In essence, not all IAuthenticators can solve all challenges at once (even though right now, the Apache Authenticator can). Authenticators can now return a None value in the place of responses they can't satisfy at the moment. The controlling script will loop around and try again. This allows Authenticators like Apache to still operate and solve 30 DVSNI challenges at once.... without requiring it upon all Authenticators.

We needed a formalized way to pass the list of Challenges to the Authenticator. I chose to add namedtuples to challenge_util.py that are aimed to include all the information the Authenticator needs to solve each challenge. (This is generally the ACME challenge message fields with the domain and perhaps authorization key).

This is fairly simple for the standard case of a single challenge message, but with the addition of the "authorization protocol" (multiple return trips to the perform function for None responses), I decided to finish the functionality and show an example of why this is useful by allowing multiple names for the authorizations. This is useful to get certificates with subject alternative names (UCC certificates in CA nomenclature). You can now request multiple names on the client side and satisfy them all at once.

In order to do this within the ACME protocol, you must attain multiple challenge messages (one for each name). This required some indexing problems...you must select specific challenges out of the message to satisfy it... you have multiple messages and you must maintain order while passing them as a giant single list to Authenticators. This created some complex logic (which I ended up moving to a new AuthHandler object), which uses master dicts with...keys; domains, values: associated list. (I believe this is better than my original multidimensional array solution, which @kuba correctly identified as overly complicated... Thanks!)

Given this flexibility and different capabilities #156 I created get_chall_pref(domain) functions that allows the Authenticator's to state their preferences based on the domain name in question. Imagine the ClientAuthenticator already knows the recoveryToken for example.com and doesn't have to ask a human about it. They can place the recoveryToken challenge appropriately and solve the challenges they are efficient at solving. (If you leave out the preference for a challenge, it is assumed that the Authenticator can't handle it and you will not be given that challenge type for the domain)

Finally, there is a notion of Client Challenges and DV challenges as delineated in CONFIG.py. Client Challenges (recoveryToken, recoveryContact, proofOfPossession) are better solved by the client's main infrastructure and shouldn't have to be reimplemented for every Authenticator plugin (nginx, stand-alone ect...)

Given all of this new logic I made the AuthHandler and ClientAuthenticator classes, where an AuthHandler contains both a "dv" Authenticator and a ClientAuthenticator instance and assigns the appropriate challenges to each Authenticator. The auth_handler will also have to do things like cache authorizations for domains in the future so I believe the additional class is justified.

Now the client just adds challenge messages to the AuthHandler and requests authorizations. The only thing I dislike about the coupling is that I didn't immediately determine a good way to keep the send_authorizations logic within the client. AuthHandler contains a network object to achieve this. It is probably possible to do with a bit more logic in the client and a generator, but I think it is OK for now and large improvement.

I tried to add tests for all of the new code and any code that I was fairly certain about within the functions I was touching. All of the configuration code needs many more tests/config scenerios... but that will be the toughest to get right and will require lots of hands-on debugging and experimenting when I get around to really nailing down that code.

PS: Although the client is setup to handle multiple authorizations at once... the server still doesn't handle this case. I will be attempting to make a branch that works with the more complete Anvil ACME implementation here soon.

jdkasten added a commit that referenced this pull request Jan 15, 2015
@jdkasten
jdkasten merged commit 55694f8 into master Jan 15, 2015
@jdkasten
jdkasten deleted the dvsni_cleanup branch January 15, 2015 22:10
eq19 pushed a commit to VirtualNetworks/cerbot that referenced this pull request May 2, 2025
certbot#162 mentions something like this, which made me notice the problem. Thanks @newbeex!
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