From 69366580192c127dd4f24ad6b3676cd55274292e Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Sun, 25 Oct 2015 19:30:29 -0600 Subject: [PATCH] letsencrypt: Work with latest lego changes --- config/letsencrypt/letsencrypt.go | 6 +++--- config/letsencrypt/renew.go | 4 ++-- main.go | 7 +++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/config/letsencrypt/letsencrypt.go b/config/letsencrypt/letsencrypt.go index 279d23a2..632e8000 100644 --- a/config/letsencrypt/letsencrypt.go +++ b/config/letsencrypt/letsencrypt.go @@ -152,7 +152,7 @@ func newClient(leEmail string) (*acme.Client, error) { } // The client facilitates our communication with the CA server. - client := acme.NewClient(caURL, &leUser, rsaKeySizeToUse, exposePort, true) // TODO: Dev mode is enabled + client := acme.NewClient(caURL, &leUser, rsaKeySizeToUse, exposePort) // If not registered, the user must register an account with the CA // and agree to terms @@ -164,7 +164,7 @@ func newClient(leEmail string) (*acme.Client, error) { leUser.Registration = reg // TODO: we can just do the agreement once: when registering, right? - err = client.AgreeToTos() + err = client.AgreeToTOS() if err != nil { saveUser(leUser) // TODO: Might as well try, right? Error check? return nil, errors.New("error agreeing to terms: " + err.Error()) @@ -189,7 +189,7 @@ func obtainCertificates(client *acme.Client, serverConfigs []*server.Config) ([] hosts = append(hosts, cfg.Host) } - certificates, err := client.ObtainCertificates(hosts) + certificates, err := client.ObtainCertificates(hosts, true) if err != nil { return nil, errors.New("error obtaining certs: " + err.Error()) } diff --git a/config/letsencrypt/renew.go b/config/letsencrypt/renew.go index 40f376cb..291df06c 100644 --- a/config/letsencrypt/renew.go +++ b/config/letsencrypt/renew.go @@ -84,10 +84,10 @@ func processCertificateRenewal(configs []server.Config) []error { // Renew certificate. // TODO: revokeOld should be an option in the caddyfile - newCertMeta, err := client.RenewCertificate(certMeta, true) + newCertMeta, err := client.RenewCertificate(certMeta, true, true) if err != nil { time.Sleep(10 * time.Second) - newCertMeta, err = client.RenewCertificate(certMeta, true) + newCertMeta, err = client.RenewCertificate(certMeta, true, true) if err != nil { errs = append(errs, err) continue diff --git a/main.go b/main.go index 21a3ae50..b080d663 100644 --- a/main.go +++ b/main.go @@ -89,13 +89,12 @@ func main() { log.Fatal("FILE LISTENER:", err) } - var ok bool - ln, ok = ln.(server.ListenerFile) + lnf, ok := ln.(server.ListenerFile) if !ok { log.Fatal("Listener was not a ListenerFile") } - err = s.Serve(ln.(server.ListenerFile)) + err = s.Serve(lnf) // TODO: Better error logging... also, is it even necessary? if err != nil { log.Println(err) @@ -204,7 +203,7 @@ func loadConfigs() (config.Group, error) { } } - // Command line Arg + // Command line args if flag.NArg() > 0 { confBody := ":" + config.DefaultPort + "\n" + strings.Join(flag.Args(), "\n") return config.Load("args", bytes.NewBufferString(confBody))