From 474c029149bfa712dc6cbc2918215d430a937a63 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Fri, 18 Dec 2015 19:05:17 +0100 Subject: Refactor keysize --- acme.toml | 2 +- cmd/acme/config.go | 32 ++++++++++++++++---------------- cmd/acme/main.go | 4 ++-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/acme.toml b/acme.toml index abd8a8e..69e4b30 100644 --- a/acme.toml +++ b/acme.toml @@ -4,7 +4,7 @@ listen = "localhost:8443" basedir = ".acme" # usually "/etc/ssl" provider = "les" account = "webmaster" -keysize = 2048 +size = 2048 [provider.lev1] directory = "https://acme-v01.api.letsencrypt.org/directory" diff --git a/cmd/acme/config.go b/cmd/acme/config.go index d9d6200..b5bc433 100644 --- a/cmd/acme/config.go +++ b/cmd/acme/config.go @@ -26,7 +26,7 @@ type defaults struct { Provider string Account string Basedir string - KeySize int + Size int } type provider struct { @@ -34,11 +34,11 @@ type provider struct { } type account struct { - Mail string - Phone string - KeySize int - Key string - key *rsa.PrivateKey + Mail string + Phone string + Size int + Key string + key *rsa.PrivateKey } type hook struct { @@ -49,7 +49,7 @@ type desire struct { Provider string Account string Altnames []string - KeySize int + Size int Key string Cert string Webroot string @@ -77,12 +77,12 @@ func LoadConfig(fname string) (*Config, error) { return nil, err } // apply defaults - if c.Defaults.KeySize == 0 { - c.Defaults.KeySize = 2048 + if c.Defaults.Size == 0 { + c.Defaults.Size = 2048 } for k, v := range c.Account { - if v.KeySize == 0 { - v.KeySize = c.Defaults.KeySize + if v.Size == 0 { + v.Size = c.Defaults.Size } if v.Mail == "" { return nil, errNoMail @@ -112,8 +112,8 @@ func LoadConfig(fname string) (*Config, error) { } } v.account = c.Account[v.Account] - if v.KeySize == 0 { - v.KeySize = c.Defaults.KeySize + if v.Size == 0 { + v.Size = c.Defaults.Size } if v.Key == "" { return nil, errNoKey @@ -141,7 +141,7 @@ func LoadConfig(fname string) (*Config, error) { type PrivKey interface { KeyPath() string - Size() int + KeySize() int KeyExists() bool } @@ -159,12 +159,12 @@ func exists(fname string) bool { func (d desire) CertPath() string { return d.Cert } func (d desire) KeyPath() string { return d.Key } -func (d desire) Size() int { return d.KeySize } +func (d desire) KeySize() int { return d.Size } func (d desire) KeyExists() bool { return exists(d.Key) } func (d desire) CertExists() bool { return exists(d.Cert) } func (a account) KeyPath() string { return a.Key } -func (a account) Size() int { return a.KeySize } +func (a account) KeySize() int { return a.Size } func (a account) KeyExists() bool { return exists(a.Key) } type duration struct{ time.Duration } diff --git a/cmd/acme/main.go b/cmd/acme/main.go index 1a4f4f2..a1a6870 100644 --- a/cmd/acme/main.go +++ b/cmd/acme/main.go @@ -23,7 +23,7 @@ func chkKey(k PrivKey) (*rsa.PrivateKey, error) { defer fd.Close() return acme.LoadKey(fd) } else { - log.Println("allocating", key, k.Size()) + log.Println("allocating", key, k.KeySize()) if err := os.MkdirAll(path.Dir(key), 0700); err != nil { return nil, err } @@ -33,7 +33,7 @@ func chkKey(k PrivKey) (*rsa.PrivateKey, error) { return nil, err } defer fd.Close() - return acme.NewKey(fd, k.Size()) + return acme.NewKey(fd, k.KeySize()) } } -- cgit v1.2.3