aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/acme/file.go17
1 files changed, 1 insertions, 16 deletions
diff --git a/cmd/acme/file.go b/cmd/acme/file.go
index ae2ade8..abd5a61 100644
--- a/cmd/acme/file.go
+++ b/cmd/acme/file.go
@@ -4,24 +4,15 @@ import (
"crypto"
"crypto/tls"
"crypto/x509"
- "errors"
"io"
"os"
"path"
- "syscall"
"dim13.org/acme"
)
-var ErrNotFound = errors.New("file not found")
-
func NewFile(fname string, mode os.FileMode) (io.WriteCloser, error) {
- err := os.Rename(fname, fname+".bak")
- if err != nil {
- if e, ok := err.(*os.LinkError); ok && e.Err != syscall.ENOENT {
- return nil, err
- }
- }
+ _ = os.Rename(fname, fname+".bak")
flags := os.O_WRONLY | os.O_CREATE | os.O_TRUNC
return os.OpenFile(fname, flags, mode)
}
@@ -72,9 +63,6 @@ func (d domain) Save(cert tls.Certificate) error {
func (d domain) Load() (tls.Certificate, error) {
crt, err := tls.LoadX509KeyPair(d.CrtFile, d.KeyFile)
if err != nil {
- if e, ok := err.(*os.PathError); ok && e.Err == syscall.ENOENT {
- err = ErrNotFound
- }
return tls.Certificate{}, err
}
crt.Leaf, err = x509.ParseCertificate(crt.Certificate[0])
@@ -96,9 +84,6 @@ func (a account) Save(key crypto.PrivateKey) error {
func (a account) Load() (crypto.PrivateKey, error) {
fd, err := os.Open(a.KeyFile)
if err != nil {
- if e, ok := err.(*os.PathError); ok && e.Err == syscall.ENOENT {
- err = ErrNotFound
- }
return nil, err
}
defer fd.Close()