quickstart: if initial address has non-ascii localpart, use "postmaster@" for registering with let's encrypt

because let's encrypt won't create an account for contact addresses with non-ascii characters.
we'll get an error message like:

	400 urn:ietf:params:acme:error:invalidContact: Error creating new account :: contact email [\"mailto:...\"] contains non-ASCII characters

found & reported by arnt, thanks!
This commit is contained in:
Mechiel Lukkien 2024-04-11 23:58:40 +02:00
parent ad8c5616b1
commit f4b6e14cb9
No known key found for this signature in database

View file

@ -650,15 +650,26 @@ many authentication failures).
Hostname: dnshostname.Name(),
AdminPasswordFile: "adminpasswd",
}
// todo: let user specify an alternative fallback address?
// Don't attempt to use a non-ascii localpart with Let's Encrypt, it won't work.
// Messages to postmaster will get to the account too.
var contactEmail string
if addr.Localpart.IsInternational() {
contactEmail = smtp.Address{Localpart: "postmaster", Domain: addr.Domain}.Pack(false)
} else {
contactEmail = addr.Pack(false)
}
if !existingWebserver {
sc.ACME = map[string]config.ACME{
"letsencrypt": {
DirectoryURL: "https://acme-v02.api.letsencrypt.org/directory",
ContactEmail: args[0], // todo: let user specify an alternative fallback address?
ContactEmail: contactEmail,
IssuerDomainName: "letsencrypt.org",
},
}
}
dataDir := "data" // ../data is relative to config/
os.MkdirAll(dataDir, 0770)
adminpw := pwgen()