Skip to content

Commit

Permalink
ECDSA account key support
Browse files Browse the repository at this point in the history
  • Loading branch information
hlandau committed Jan 20, 2016
1 parent 0758ac9 commit 231ce74
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
3 changes: 2 additions & 1 deletion cmd/acmetool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"path/filepath"
"strings"

//"github.com/hlandau/acme/acmeapi"
"github.com/hlandau/acme/acmeapi"
"github.com/hlandau/acme/hooks"
"github.com/hlandau/acme/interaction"
"github.com/hlandau/acme/redirector"
Expand Down Expand Up @@ -99,6 +99,7 @@ func main() {
adaptflag.Adapt()
cmd := kingpin.Parse()
hooks.DefaultPath = *hooksFlag
acmeapi.UserAgent = "acmetool"
xlogconfig.Init()

if *batchFlag {
Expand Down
5 changes: 3 additions & 2 deletions storage/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/base32"
"fmt"
"github.com/hlandau/acme/acmeapi"
"github.com/jmhodges/clock"
"github.com/satori/go.uuid"
"strings"
"time"
Expand Down Expand Up @@ -56,8 +57,8 @@ type Authorization struct {
}

// Returns true iff the authorization is unexpired.
func (a *Authorization) IsValid() bool {
return time.Now().Before(a.Expires)
func (a *Authorization) IsValid(clock clock.Clock) bool {
return clock.Now().Before(a.Expires)
}

// Represents the "satisfy" section of a target file.
Expand Down
16 changes: 8 additions & 8 deletions storageops/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ import (
"github.com/hlandau/acme/solver"
"github.com/hlandau/acme/storage"
"github.com/hlandau/xlog"
"github.com/jmhodges/clock"
"golang.org/x/net/context"
"sort"
"time"
)

var log, Log = xlog.New("acme.reconcilator")

// Internal use only. Used for testing purposes. Do not change.
var InternalClock = clock.Default()

type reconcile struct {
store storage.Store
}
Expand Down Expand Up @@ -87,9 +90,6 @@ func (r *reconcile) Relink() error {
log.Tracef("relink: best certificate satisfying %v is %v", tgt, c)

cprev, err := r.store.PreferredCertificateForHostname(name)
if err != nil {
log.Errore(err, "get preferred certificate for hostname")
}

if c != cprev || err != nil {
log.Debugf("relinking: %v -> %v (was %v)", name, c, cprev)
Expand Down Expand Up @@ -370,7 +370,7 @@ func (r *reconcile) determineNecessaryAuthorizations(names []string, a *storage.
}

for _, auth := range a.Authorizations {
if auth.IsValid() {
if auth.IsValid(InternalClock) {
delete(needed, auth.Name)
}
}
Expand Down Expand Up @@ -465,7 +465,7 @@ func (r *reconcile) getAccountByDirectoryURL(directoryURL string) (*storage.Acco
}

func (r *reconcile) createNewAccount(directoryURL string) (*storage.Account, error) {
pk, err := generateKey(&storage.TargetRequestKey{}) // TODO
pk, err := generateKey(&r.store.DefaultTarget().Request.Key)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -705,8 +705,8 @@ func CertificateNeedsRenewing(c *storage.Certificate) bool {
return false
}

renewSpan := renewTime(cc.NotBefore, cc.NotAfter)
needsRenewing := !time.Now().Before(renewSpan)
renewTime := renewTime(cc.NotBefore, cc.NotAfter)
needsRenewing := !InternalClock.Now().Before(renewTime)

log.Debugf("%v needsRenewing=%v notAfter=%v", c, needsRenewing, cc.NotAfter)
return needsRenewing
Expand Down

0 comments on commit 231ce74

Please sign in to comment.