aboutsummaryrefslogtreecommitdiff
path: root/cmd/acme/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/acme/config.go')
-rw-r--r--cmd/acme/config.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/cmd/acme/config.go b/cmd/acme/config.go
index 7ed5bcb..d9d6200 100644
--- a/cmd/acme/config.go
+++ b/cmd/acme/config.go
@@ -4,6 +4,7 @@ import (
"crypto/rsa"
"crypto/x509"
"errors"
+ "os"
"path"
"strings"
"time"
@@ -141,17 +142,30 @@ func LoadConfig(fname string) (*Config, error) {
type PrivKey interface {
KeyPath() string
Size() int
+ KeyExists() bool
}
type Cert interface {
CertPath() string
+ CertExists() bool
+}
+
+func exists(fname string) bool {
+ if _, err := os.Stat(fname); os.IsNotExist(err) {
+ return false
+ }
+ return true
}
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) 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) KeyExists() bool { return exists(a.Key) }
type duration struct{ time.Duration }