Commit d36685ac authored by Matthew Holt's avatar Matthew Holt

letsencrypt: Fix bug if different emails used; beta 2

parent 051d2a68
...@@ -75,16 +75,22 @@ func Activate(configs []server.Config) ([]server.Config, error) { ...@@ -75,16 +75,22 @@ func Activate(configs []server.Config) ([]server.Config, error) {
// obtain certificates for configs that need one, and reconfigure each // obtain certificates for configs that need one, and reconfigure each
// config to use the certificates // config to use the certificates
for leEmail, serverConfigs := range groupedConfigs { for leEmail, cfgIndexes := range groupedConfigs {
// make client to service this email address with CA server // make client to service this email address with CA server
client, err := newClient(leEmail) client, err := newClient(leEmail)
if err != nil { if err != nil {
return configs, errors.New("error creating client: " + err.Error()) return configs, errors.New("error creating client: " + err.Error())
} }
// little bit of housekeeping; gather the hostnames into a slice
hosts := make([]string, len(cfgIndexes))
for i, idx := range cfgIndexes {
hosts[i] = configs[idx].Host
}
// client is ready, so let's get free, trusted SSL certificates! // client is ready, so let's get free, trusted SSL certificates!
Obtain: Obtain:
certificates, failures := obtainCertificates(client, serverConfigs) certificates, failures := client.ObtainCertificates(hosts, true)
if len(failures) > 0 { if len(failures) > 0 {
// Build an error string to return, using all the failures in the list. // Build an error string to return, using all the failures in the list.
var errMsg string var errMsg string
...@@ -122,8 +128,8 @@ func Activate(configs []server.Config) ([]server.Config, error) { ...@@ -122,8 +128,8 @@ func Activate(configs []server.Config) ([]server.Config, error) {
} }
// it all comes down to this: turning on TLS with all the new certs // it all comes down to this: turning on TLS with all the new certs
for i := 0; i < len(serverConfigs); i++ { for _, idx := range cfgIndexes {
configs = autoConfigure(configs, i) configs = autoConfigure(configs, idx)
} }
} }
...@@ -180,8 +186,8 @@ func configQualifies(allConfigs []server.Config, cfgIndex int) bool { ...@@ -180,8 +186,8 @@ func configQualifies(allConfigs []server.Config, cfgIndex int) bool {
// If an email address is not available for an eligible config, the user will be // If an email address is not available for an eligible config, the user will be
// prompted to provide one. The returned map contains pointers to the original // prompted to provide one. The returned map contains pointers to the original
// server config values. // server config values.
func groupConfigsByEmail(configs []server.Config) (map[string][]*server.Config, error) { func groupConfigsByEmail(configs []server.Config) (map[string][]int, error) {
initMap := make(map[string][]*server.Config) initMap := make(map[string][]int)
for i := 0; i < len(configs); i++ { for i := 0; i < len(configs); i++ {
// filter out configs that we already have certs for and // filter out configs that we already have certs for and
// that we won't be obtaining certs for - this way we won't // that we won't be obtaining certs for - this way we won't
...@@ -191,7 +197,7 @@ func groupConfigsByEmail(configs []server.Config) (map[string][]*server.Config, ...@@ -191,7 +197,7 @@ func groupConfigsByEmail(configs []server.Config) (map[string][]*server.Config,
continue continue
} }
leEmail := getEmail(configs[i]) leEmail := getEmail(configs[i])
initMap[leEmail] = append(initMap[leEmail], &configs[i]) initMap[leEmail] = append(initMap[leEmail], i)
} }
return initMap, nil return initMap, nil
} }
...@@ -270,7 +276,7 @@ func newClientPort(leEmail, port string) (*acme.Client, error) { ...@@ -270,7 +276,7 @@ func newClientPort(leEmail, port string) (*acme.Client, error) {
// obtainCertificates obtains certificates from the CA server for // obtainCertificates obtains certificates from the CA server for
// the configurations in serverConfigs using client. // the configurations in serverConfigs using client.
func obtainCertificates(client *acme.Client, serverConfigs []*server.Config) ([]acme.CertificateResource, map[string]error) { func obtainCertificates(client *acme.Client, serverConfigs []server.Config) ([]acme.CertificateResource, map[string]error) {
// collect all the hostnames into one slice // collect all the hostnames into one slice
var hosts []string var hosts []string
for _, cfg := range serverConfigs { for _, cfg := range serverConfigs {
......
CADDY 0.8 beta CADDY 0.8 beta 2
Website Website
https://caddyserver.com https://caddyserver.com
......
...@@ -24,7 +24,7 @@ var ( ...@@ -24,7 +24,7 @@ var (
const ( const (
appName = "Caddy" appName = "Caddy"
appVersion = "0.8 beta" appVersion = "0.8 beta 2"
) )
func init() { func init() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment