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

Add Let's Encrypt HTTP Challenge #2701

Merged
merged 15 commits into from
Jan 15, 2018
Merged

Conversation

juliens
Copy link
Member

@juliens juliens commented Jan 12, 2018

What does this PR do?

Until now, Træfik only allowed TLS-SNI-01 and DNS-01 challenges to generate/renew ACME certificates.
This PR allows users to generate/renew ACME certificates thanks to the HTTP-01 challenge.

Motivation

Due to a security vulnerability, Let's Encrypt disabled TLS-SNI-01 challenges.
More information here and here.

Fixes #1832

More

  • Added/updated tests
  • Added/updated documentation

Additional Notes

  • For now, TLS-SNI-01 stays the default challenge in Træfik. If this challenge becomes definitively disabled, it will be removed from Træfik in future versions.
  • HTTP-01 challenge requires an HTTP entry point which can be accessed through the port 80 by Let's Encrypt.
  • The acme configuration has to evolve in Træfik, many fields will be deprecated by this PR.

@traefiker traefiker added this to the 1.5 milestone Jan 12, 2018
@ldez ldez changed the title Add HTTP Challenge Add ACME HTTP Challenge Jan 12, 2018
Copy link
Member

@emilevauge emilevauge left a comment

Choose a reason for hiding this comment

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

Great job !
Few comments though ;)

acme/acme.go Outdated
}

type DNSChallenge struct {
DNSProvider string `description:"Use a DNS based challenge provider rather than HTTPS."`
Copy link
Member

Choose a reason for hiding this comment

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

s/DNSProvider/Provider

acme/acme.go Outdated
}

type HTTPChallenge struct {
EntryPoint string `description: "HTTP EntryPoint for challenge to"`
Copy link
Member

Choose a reason for hiding this comment

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

HTTP EntryPoint for challenge to => HTTP challenge EntryPoint

acme/acme.go Outdated
router.Methods(http.MethodGet).Path(acme.HTTP01ChallengePath("{token}")).Handler(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
vars := mux.Vars(req)
if token, ok := vars["token"]; ok {
domain, _, _ := net.SplitHostPort(req.Host)
Copy link
Member

Choose a reason for hiding this comment

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

err should not be ignored

acme/account.go Outdated
@@ -24,6 +24,7 @@ type Account struct {
PrivateKey []byte
DomainsCertificate DomainsCertificates
ChallengeCerts map[string]*ChallengeCert
HttpChallenge map[string]map[string][]byte
Copy link
Member

Choose a reason for hiding this comment

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

We really need to add an integration test to check that we support old acme.json.

acme/acme.go Outdated
@@ -155,7 +196,8 @@ func (a *ACME) CreateClusterConfig(leadership *cluster.Leadership, tlsConfig *tl
}

a.store = datastore
a.challengeProvider = &challengeProvider{store: a.store}
a.challengeTLSProvider = &challengeTLSProvider{store: a.store}
a.challengeHTTPProvider = &challengeHTTPProvider{store: a.store}
Copy link
Member

Choose a reason for hiding this comment

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

I'm not in love with instantiating challengeTLSProvider & challengeHTTPProvider here.

acme/acme.go Outdated
if a.OnDemand {
log.Warn("ACME.OnDemand is deprecated")
}

Copy link
Member

Choose a reason for hiding this comment

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

I would use SetEffectiveConfiguration() to initialize the configuration correctly instead of init()

@dfeyer
Copy link

dfeyer commented Jan 12, 2018

Based on https://community.letsencrypt.org/t/2018-01-11-update-regarding-acme-tls-sni-and-shared-hosting-infrastructure/50188 I think you can change the default ...

And a huge thanks for your reactivity to implement HTTP-01

@ldez ldez force-pushed the challenge-http branch 2 times, most recently from bcef1c8 to 23ce35e Compare January 13, 2018 01:43
caServer = "http://172.18.0.1:4000/directory"
entryPoint = "https"
[acme.dsnChallenge]
Copy link

Choose a reason for hiding this comment

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

typo

@markuslackner
Copy link

markuslackner commented Jan 13, 2018

This fix does not work for me. I get Error while ACME challenge: address test.test.at: missing port in address. I took a quick look into the code and think: In acme.go

domain, _, err := net.SplitHostPort(req.Host) 

is getting only the host without port and failing. So for now i'm stuck. I have no idea, why this is not working for me, but obviously works for others. My setup is quite basic: traefik on docker with no special thinks (i reduced the config mostly to the basic example).

@ldez
Copy link
Contributor

ldez commented Jan 13, 2018

@markuslackner Could you go to the Traefik community Slack in the channel #support and give more information about your configuration.

Edit: the problem is now fixed 🎉

@ldez ldez force-pushed the challenge-http branch 2 times, most recently from 6319c3d to 6d91f55 Compare January 13, 2018 14:33
@mhajder
Copy link

mhajder commented Jan 15, 2018

The official unofficial image.
Use from here: https://hub.docker.com/r/containous/traefik/
docker pull containous/traefik:latest

@kruemelro
Copy link

I'm still getting the
acme: Could not determine solvers
Error with the latest Version. Did i've overseen something?

@mhajder
Copy link

mhajder commented Jan 15, 2018

@kruemelro Remember to download a new image and clear the cache.
Do not forget to add:

[acme.httpChallenge]
entryPoint = "http"

to config file (traefik.toml)

@ldez
Copy link
Contributor

ldez commented Jan 15, 2018

The documentation http://v1-5.archive.docs.traefik.io/configuration/acme/#acmehttpchallenge

Please don't use containous/traefik:latest

@mhajder
Copy link

mhajder commented Jan 15, 2018

@ldez Currently it is the only way because Docker has not yet released a new version of the official image.

@ldez
Copy link
Contributor

ldez commented Jan 15, 2018

I know but we don't recommend the use of this image.

@traefik traefik locked and limited conversation to collaborators Jan 15, 2018
@traefik traefik unlocked this conversation Jan 15, 2018
@ldez
Copy link
Contributor

ldez commented Jan 15, 2018

The official image is available: docker pull traefik:v1.5.0-rc5

@hugglesfox
Copy link

@ldez When I try run docker pull traefik:v1.5.0-rc5 on my raspberry pi I get ERROR: no matching manifest for linux/arm in the manifest list entries.

@ldez
Copy link
Contributor

ldez commented Jan 15, 2018

@HUg0005 I think some images are still under construction, you need to wait.
If you always have this problem in 3-4 hours, come on the Traefik community Slack to inform us.

@alexandre-leites
Copy link

Hi,

I'm following this PR since the beginning. Thanks all for the efforts. Can I still use the redirection to https entrypoint enabled on the http entrypoint or it won't work properly with the HTTP-01 validation?

If no, how can I redirect anything besides the validation to https entrypoint?

Thanks.

@ldez
Copy link
Contributor

ldez commented Jan 15, 2018

@xalexslx you can still use the redirection.

@signaleleven
Copy link

Just rebuilt my container with traefik:1.5 and the new acme config: works like a charm.
THANKS to everyone involved, it's been a pleasure seeing the project reacting to this. I'm humbled by such awesomeness. You guys rock.

@vrosales
Copy link

Hi, i am getting 400/timeout when enabling HTTP-01, is there anything else i am supposed to do beside enabling the challenge?

time="2018-01-16T13:28:28Z" level=error msg="Error getting ACME certificates [staging2.example.com] : cannot obtain certificates map[staging2.example.com:acme: Error 400 - urn:acme:error:connection - Fetching http://staging2.example.com/.well-known/acme-challenge/Gw8J6YHJRYT6Tokf3moo8WzzdHuOXe9qcofZ38KuPpk: Timeout
Error Detail:
    Validation for staging2.example.com:80
    Resolved to:
	    XX.XX.XX.XX
    Used: XX.XX.XX.XX

@nmengin
Copy link
Contributor

nmengin commented Jan 16, 2018

@vrosales Can you come on the Traefik community Slack to give us more information about your configuration?

@traefik traefik locked and limited conversation to collaborators Jan 16, 2018
@ldez
Copy link
Contributor

ldez commented Jan 20, 2018

Due to the number of question about redirection:

The redirection is fully compatible with the HTTP-01 challenge.

You can use redirection with HTTP-01 challenge without problem.

Enjoy 🎉

@juliens juliens deleted the challenge-http branch January 25, 2018 20:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/acme kind/enhancement a new or improved feature. priority/P0 needs hot fix size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.