commit
						e484576b95
					
				|  | @ -9,6 +9,8 @@ import ( | ||||||
| 	"os" | 	"os" | ||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
|  | 	"rsc.io/letsencrypt" | ||||||
|  | 
 | ||||||
| 	log "github.com/Sirupsen/logrus" | 	log "github.com/Sirupsen/logrus" | ||||||
| 	"github.com/Sirupsen/logrus/formatters/logstash" | 	"github.com/Sirupsen/logrus/formatters/logstash" | ||||||
| 	"github.com/bugsnag/bugsnag-go" | 	"github.com/bugsnag/bugsnag-go" | ||||||
|  | @ -111,11 +113,10 @@ func (registry *Registry) ListenAndServe() error { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if config.HTTP.TLS.Certificate != "" { | 	if config.HTTP.TLS.Certificate != "" || config.HTTP.TLS.LetsEncrypt.CacheFile != "" { | ||||||
| 		tlsConf := &tls.Config{ | 		tlsConf := &tls.Config{ | ||||||
| 			ClientAuth:               tls.NoClientCert, | 			ClientAuth:               tls.NoClientCert, | ||||||
| 			NextProtos:               []string{"http/1.1"}, | 			NextProtos:               []string{"http/1.1"}, | ||||||
| 			Certificates:             make([]tls.Certificate, 1), |  | ||||||
| 			MinVersion:               tls.VersionTLS10, | 			MinVersion:               tls.VersionTLS10, | ||||||
| 			PreferServerCipherSuites: true, | 			PreferServerCipherSuites: true, | ||||||
| 			CipherSuites: []uint16{ | 			CipherSuites: []uint16{ | ||||||
|  | @ -130,9 +131,26 @@ func (registry *Registry) ListenAndServe() error { | ||||||
| 			}, | 			}, | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		tlsConf.Certificates[0], err = tls.LoadX509KeyPair(config.HTTP.TLS.Certificate, config.HTTP.TLS.Key) | 		if config.HTTP.TLS.LetsEncrypt.CacheFile != "" { | ||||||
| 		if err != nil { | 			if config.HTTP.TLS.Certificate != "" { | ||||||
| 			return err | 				return fmt.Errorf("cannot specify both certificate and Let's Encrypt") | ||||||
|  | 			} | ||||||
|  | 			var m letsencrypt.Manager | ||||||
|  | 			if err := m.CacheFile(config.HTTP.TLS.LetsEncrypt.CacheFile); err != nil { | ||||||
|  | 				return err | ||||||
|  | 			} | ||||||
|  | 			if !m.Registered() { | ||||||
|  | 				if err := m.Register(config.HTTP.TLS.LetsEncrypt.Email, nil); err != nil { | ||||||
|  | 					return err | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 			tlsConf.GetCertificate = m.GetCertificate | ||||||
|  | 		} else { | ||||||
|  | 			tlsConf.Certificates = make([]tls.Certificate, 1) | ||||||
|  | 			tlsConf.Certificates[0], err = tls.LoadX509KeyPair(config.HTTP.TLS.Certificate, config.HTTP.TLS.Key) | ||||||
|  | 			if err != nil { | ||||||
|  | 				return err | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if len(config.HTTP.TLS.ClientCAs) != 0 { | 		if len(config.HTTP.TLS.ClientCAs) != 0 { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue