Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

Fixes for issue #52 #56

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,12 @@ func readKey(path string) (crypto.Signer, error) {
}

// writeKey writes k to the specified path in PEM format.
// If file does not exists, it will be created with 0600 mod.
// If directory of path does not exist, it will be created with 0700 mod.
// If path does not exists, it will be created with 0600 mod.
func writeKey(path string, k *ecdsa.PrivateKey) error {
if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {
return err
}
f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {
return err
Expand Down
8 changes: 7 additions & 1 deletion reg.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ package main

import (
"context"
"os"
"fmt"
"path/filepath"
"strings"
Expand Down Expand Up @@ -87,7 +88,12 @@ func runReg(args []string) {

a, err := client.Register(ctx, &uc.Account, prompt)
if err != nil {
fatalf("%v", err)
switch err.Error() {
case "409 urn:acme:error:malformed: Registration key is already in use":
fatalf("Key already registered - see '%s whoami -c %s'.\nMaybe you just need to accept an updated license?\nThen you can use '%s update -c %s -accept'", os.Args[0], configDir, os.Args[0], configDir)
default:
fatalf("%v", err)
}
}
uc.Account = *a
if err := writeConfig(uc); err != nil {
Expand Down