Skip to content

Conversation

@jehiah
Copy link
Contributor

@jehiah jehiah commented Jan 15, 2016

This implements the last suggestion from #32 by @janeczku to separate solving the http-01 challenge, from making the keyAuth available at the appropriate path.

This change creates a new interface

type HTTPChallengeProvider interface {
    PresentToken(domain, path, keyAuth string) error
    CleanUp(domain, path string)
}

And a httpChallengeServer (extracted from httpChallenge) which implements that interface and is used by Client.

I am looking to use lego as a library to generate certs and will need to have my own logic for making the token available, so the suggestion in #32 was quite useful.

@xenolf If you have any thoughts on this change (or suggestions on impelemtnation) i'm all ears.

@xenolf
Copy link
Member

xenolf commented Jan 15, 2016

Hey there :)
Thank you for your contribution!

The change in itself looks sound. What I'm thinking about at the moment is though if it would make sense to have a general interface to all challenges along this implementation.
We will need something like this for DNS-01 and TLS-SNI-01 as well. Some discussion about this is going on in #36.

@jehiah
Copy link
Contributor Author

jehiah commented Jan 20, 2016

@xenolf can you take another look. This incorporates feedback from #36 and exports a generic interface which (i think) will work for all challenges.

type ChallengeProvider interface {
    Present(domain, token, keyAuth string) error
    CleanUp(domain string)
 }

Then there is a un-exported https and tls provider (ie: the http/tls servers that are the default providers for this package), and an exported function to set a custom providers, and exported helpers build the path for the http-01 challenge, and the cert for the tls-sni-01 challenge.

I'm of the opinion that this package should not export ProvidersOpts (as mentioned in #36) as that is a concept that concrete implementations need to care about; this package just exports the interface any provider needs to implement to be callable by the appropriate challenge setup/teardown before the solver is run.

I've tried to keep things named consistently, but if you have better naming suggestions on anything, just comment. I'm also happy to apply this refactoring to the dns provider when that lands in master

@jehiah jehiah force-pushed the custom_http_challenge_76 branch from 735027e to 6dae9f2 Compare January 22, 2016 04:17
@jehiah
Copy link
Contributor Author

jehiah commented Jan 22, 2016

@xenolf I see you've started landing support for dns-01 challenge in master. I've rebased this and applied the same ChallengeProvider interface to the DNS code contained within. I'm not perfectly confident my changes are perfect as i don't have a test setup for the three DNS providers that are currently implemented, but i look forward to your feedback either way.

acme/client.go Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think when going down this route we should export constants for these identifiers. Like acme.HTTP01.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea; update forthcoming

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

@jehiah jehiah force-pushed the custom_http_challenge_76 branch from ed4fc6d to 141ff45 Compare January 22, 2016 20:44
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think those should be consts.

@jehiah
Copy link
Contributor Author

jehiah commented Jan 24, 2016

@xenolf let me know if you have any other feedback here, or if you'd like me to squash what's here for merge.

@xenolf
Copy link
Member

xenolf commented Jan 24, 2016

Nah I think I'm happy now ;)
Squash it and I'll merge it in.

* new ChallengeProvider with Present and CleanUp methods
* new Challenge type describing `http-01`, `tls-sni-01`, `dns-01`
* new client.SetChallengeProvider to support custom implementations
@jehiah jehiah force-pushed the custom_http_challenge_76 branch from b9eff62 to 617dd4d Compare January 24, 2016 21:12
@jehiah
Copy link
Contributor Author

jehiah commented Jan 24, 2016

squashed

xenolf added a commit that referenced this pull request Jan 24, 2016
http-01: refactor provider for presenting token
@xenolf xenolf merged commit 0c1aded into go-acme:master Jan 24, 2016
@mholt mholt mentioned this pull request Jan 25, 2016
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 617dd4d on jehiah:custom_http_challenge_76 into ** on xenolf:master**.

@ldez ldez added this to the v0.3 milestone Dec 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants