Skip to content

Commit 73be0d8

Browse files
committed
Merge remote-tracking branch 'origin/no-email'
2 parents 441775e + 51ef22a commit 73be0d8

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

cmd/accounts_storage.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const (
5858
// │ └── root accounts directory
5959
// └── "path" option
6060
type AccountsStorage struct {
61+
noEmail bool
6162
userID string
6263
rootPath string
6364
rootUserPath string
@@ -68,8 +69,14 @@ type AccountsStorage struct {
6869

6970
// NewAccountsStorage Creates a new AccountsStorage.
7071
func NewAccountsStorage(ctx *cli.Context) *AccountsStorage {
71-
// TODO: move to account struct? Currently MUST pass email.
72-
email := getEmail(ctx)
72+
var userID string
73+
noEmail := ctx.IsSet("no-email")
74+
if noEmail {
75+
userID = "default"
76+
} else {
77+
// TODO: move to account struct?
78+
userID = getEmail(ctx)
79+
}
7380

7481
serverURL, err := url.Parse(ctx.String("server"))
7582
if err != nil {
@@ -79,10 +86,11 @@ func NewAccountsStorage(ctx *cli.Context) *AccountsStorage {
7986
rootPath := filepath.Join(ctx.String("path"), baseAccountsRootFolderName)
8087
serverPath := strings.NewReplacer(":", "_", "/", string(os.PathSeparator)).Replace(serverURL.Host)
8188
accountsPath := filepath.Join(rootPath, serverPath)
82-
rootUserPath := filepath.Join(accountsPath, email)
89+
rootUserPath := filepath.Join(accountsPath, userID)
8390

8491
return &AccountsStorage{
85-
userID: email,
92+
noEmail: noEmail,
93+
userID: userID,
8694
rootPath: rootPath,
8795
rootUserPath: rootUserPath,
8896
keysPath: filepath.Join(rootUserPath, baseKeysFolderName),
@@ -110,6 +118,9 @@ func (s *AccountsStorage) GetRootUserPath() string {
110118
}
111119

112120
func (s *AccountsStorage) GetUserID() string {
121+
if s.noEmail {
122+
return ""
123+
}
113124
return s.userID
114125
}
115126

cmd/flags.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ func CreateFlags(defaultPath string) []cli.Flag {
3232
Aliases: []string{"m"},
3333
Usage: "Email used for registration and recovery contact.",
3434
},
35+
&cli.BoolFlag{
36+
Name: "no-email",
37+
Aliases: []string{"M"},
38+
EnvVars: []string{"LEGO_NO_EMAIL"},
39+
Usage: "Create an ACME request without including an email address.",
40+
},
3541
&cli.StringFlag{
3642
Name: "csr",
3743
Aliases: []string{"c"},

cmd/setup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func getKeyType(ctx *cli.Context) certcrypto.KeyType {
8484
func getEmail(ctx *cli.Context) string {
8585
email := ctx.String("email")
8686
if email == "" {
87-
log.Fatal("You have to pass an account (email address) to the program using --email or -m")
87+
log.Fatal("You have to pass an account (email address) to the program using --email or -m, or use --no-email or -M to disable including an email in the ACME request.")
8888
}
8989
return email
9090
}

docs/data/zz_cli_help.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ GLOBAL OPTIONS:
2323
--server value, -s value CA hostname (and optionally :port). The server certificate must be trusted in order to avoid further modifications to the client. (default: "https://acme-v02.api.letsencrypt.org/directory") [$LEGO_SERVER]
2424
--accept-tos, -a By setting this flag to true you indicate that you accept the current Let's Encrypt terms of service. (default: false)
2525
--email value, -m value Email used for registration and recovery contact.
26+
--no-email, -M Create an ACME request without including an email address. (default: false) [$LEGO_NO_EMAIL]
2627
--csr value, -c value Certificate signing request filename, if an external CSR is to be used.
2728
--eab Use External Account Binding for account registration. Requires --kid and --hmac. (default: false) [$LEGO_EAB]
2829
--kid value Key identifier from External CA. Used for External Account Binding. [$LEGO_EAB_KID]

0 commit comments

Comments
 (0)