From a09886b57785b9b4d8e97feff2b8d36f90402302 Mon Sep 17 00:00:00 2001 From: xenolf Date: Wed, 10 Jun 2015 15:11:01 +0200 Subject: [PATCH] Add challengeHandler interface --- acme/client.go | 19 ++++++++++++++++++- acme/dvsni_challenge.go | 1 + acme/simple_https_challenge.go | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 acme/dvsni_challenge.go create mode 100644 acme/simple_https_challenge.go diff --git a/acme/client.go b/acme/client.go index f07d35fd..81a4fe4c 100644 --- a/acme/client.go +++ b/acme/client.go @@ -35,6 +35,11 @@ type User interface { GetPrivateKey() *rsa.PrivateKey } +type challengeHandler interface { + CanSolve() bool + Solve() +} + // Client is the user-friendy way to ACME type Client struct { regURL string @@ -146,7 +151,19 @@ func (c *Client) AgreeToTos() error { // certificate processings at the same time in parallel. func (c *Client) ObtainCertificates(domains []string) error { + challenges := c.getChallenges(domains) + c.doChallenges(challenges) + return nil +} + +func (c *Client) doChallenges(challenges []*authorizationResource) { + for _, auth := range challenges { + } +} + +func (c *Client) getChallenges(domains []string) []*authorizationResource { resc, errc := make(chan *authorizationResource), make(chan error) + for _, domain := range domains { go func(domain string) { jsonBytes, err := json.Marshal(authorization{Identifier: identifier{Type: "dns", Value: domain}}) @@ -196,7 +213,7 @@ func (c *Client) ObtainCertificates(domains []string) error { close(resc) close(errc) - return nil + return responses } func logResponseHeaders(resp *http.Response) { diff --git a/acme/dvsni_challenge.go b/acme/dvsni_challenge.go new file mode 100644 index 00000000..8d2a213b --- /dev/null +++ b/acme/dvsni_challenge.go @@ -0,0 +1 @@ +package acme diff --git a/acme/simple_https_challenge.go b/acme/simple_https_challenge.go new file mode 100644 index 00000000..8d2a213b --- /dev/null +++ b/acme/simple_https_challenge.go @@ -0,0 +1 @@ +package acme