mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-26 02:09:47 +08:00
letsencrypt: Work with latest lego changes
This commit is contained in:
parent
b5b31e398c
commit
6936658019
|
@ -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())
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
7
main.go
7
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))
|
||||
|
|
Loading…
Reference in New Issue
Block a user