diff --git a/config/config.go b/config/config.go index aa8f16f0..493e4ea8 100644 --- a/config/config.go +++ b/config/config.go @@ -20,6 +20,8 @@ const ( DefaultListenAddr = "127.0.0.1:8080" DefaultCertFile = "" DefaultKeyFile = "" + DefaultCertDomain = "" + DefaultCertCache = "/tmp/cert_cache" ) // Config manages configuration parameters. diff --git a/locale/translations.go b/locale/translations.go index a15c0446..eaa4daa8 100644 --- a/locale/translations.go +++ b/locale/translations.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// 2017-11-21 22:32:06.371264138 -0800 PST m=+0.036637447 +// 2017-11-22 12:56:32.17637034 -0800 PST m=+0.027880962 package locale @@ -20,8 +20,8 @@ var Translations = map[string]string{ "%d erreurs" ], "plural.categories.feed_count": [ - "Il y %d abonnement.", - "Il y %d abonnements." + "Il y a %d abonnement.", + "Il y a %d abonnements." ], "Username": "Nom d'utilisateur", "Password": "Mot de passe", @@ -152,5 +152,5 @@ var Translations = map[string]string{ var TranslationsChecksums = map[string]string{ "en_US": "6fe95384260941e8a5a3c695a655a932e0a8a6a572c1e45cb2b1ae8baa01b897", - "fr_FR": "9a57dded2cf33b8c4d9a9d90dcbf18c96026ca396f409eb1a776ddc206fe0198", + "fr_FR": "c5ee8f6e8d573cd4ae0aa003b4a1e72ab400484e0f22b355702bb46409743881", } diff --git a/locale/translations/fr_FR.json b/locale/translations/fr_FR.json index 3cef2a59..431ca615 100644 --- a/locale/translations/fr_FR.json +++ b/locale/translations/fr_FR.json @@ -4,8 +4,8 @@ "%d erreurs" ], "plural.categories.feed_count": [ - "Il y %d abonnement.", - "Il y %d abonnements." + "Il y a %d abonnement.", + "Il y a %d abonnements." ], "Username": "Nom d'utilisateur", "Password": "Mot de passe", diff --git a/server/server.go b/server/server.go index 1514b300..0f2533dc 100644 --- a/server/server.go +++ b/server/server.go @@ -12,6 +12,7 @@ import ( "github.com/gorilla/mux" "github.com/miniflux/miniflux2/scheduler" + "golang.org/x/crypto/acme/autocert" "github.com/miniflux/miniflux2/config" "github.com/miniflux/miniflux2/reader/feed" @@ -26,6 +27,8 @@ func NewServer(cfg *config.Config, store *storage.Storage, pool *scheduler.Worke func startServer(cfg *config.Config, handler *mux.Router) *http.Server { certFile := cfg.Get("CERT_FILE", config.DefaultCertFile) keyFile := cfg.Get("KEY_FILE", config.DefaultKeyFile) + certDomain := cfg.Get("CERT_DOMAIN", config.DefaultCertDomain) + certCache := cfg.Get("CERT_CACHE", config.DefaultCertCache) server := &http.Server{ ReadTimeout: 5 * time.Second, WriteTimeout: 10 * time.Second, @@ -34,23 +37,29 @@ func startServer(cfg *config.Config, handler *mux.Router) *http.Server { Handler: handler, } - if certFile != "" && keyFile != "" { - server.TLSConfig = &tls.Config{ - MinVersion: tls.VersionTLS12, + if certDomain != "" && certCache != "" { + server.Addr = ":https" + certManager := autocert.Manager{ + Cache: autocert.DirCache(certCache), + Prompt: autocert.AcceptTOS, + HostPolicy: autocert.HostWhitelist(certDomain), } + go func() { + log.Printf(`Listening on "%s" by using auto-configured certificate for "%s"`, server.Addr, certDomain) + log.Fatalln(server.Serve(certManager.Listener())) + }() + } else if certFile != "" && keyFile != "" { + server.TLSConfig = &tls.Config{MinVersion: tls.VersionTLS12} + go func() { log.Printf(`Listening on "%s" by using certificate "%s" and key "%s"`, server.Addr, certFile, keyFile) - if err := server.ListenAndServeTLS(certFile, keyFile); err != nil { - log.Fatalln(err) - } + log.Fatalln(server.ListenAndServeTLS(certFile, keyFile)) }() } else { go func() { log.Printf(`Listening on "%s" without TLS`, server.Addr) - if err := server.ListenAndServe(); err != nil { - log.Fatalln(err) - } + log.Fatalln(server.ListenAndServe()) }() } diff --git a/server/static/bin.go b/server/static/bin.go index 0132a9c3..d7ead299 100644 --- a/server/static/bin.go +++ b/server/static/bin.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// 2017-11-21 22:32:06.342731949 -0800 PST m=+0.008105258 +// 2017-11-22 12:56:32.154538505 -0800 PST m=+0.006049127 package static diff --git a/server/static/css.go b/server/static/css.go index 42a1cbab..413dd86d 100644 --- a/server/static/css.go +++ b/server/static/css.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// 2017-11-21 22:32:06.344826414 -0800 PST m=+0.010199723 +// 2017-11-22 12:56:32.155674865 -0800 PST m=+0.007185487 package static diff --git a/server/static/js.go b/server/static/js.go index 04a3f422..ae71a18a 100644 --- a/server/static/js.go +++ b/server/static/js.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// 2017-11-21 22:32:06.347626921 -0800 PST m=+0.013000230 +// 2017-11-22 12:56:32.159728625 -0800 PST m=+0.011239247 package static diff --git a/server/template/common.go b/server/template/common.go index ce54011e..0e633c2f 100644 --- a/server/template/common.go +++ b/server/template/common.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// 2017-11-21 22:32:06.368574596 -0800 PST m=+0.033947905 +// 2017-11-22 12:56:32.174424983 -0800 PST m=+0.025935605 package template diff --git a/server/template/views.go b/server/template/views.go index bfc0f8ac..2fd367b6 100644 --- a/server/template/views.go +++ b/server/template/views.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// 2017-11-21 22:32:06.350434639 -0800 PST m=+0.015807948 +// 2017-11-22 12:56:32.16193023 -0800 PST m=+0.013440852 package template diff --git a/sql/sql.go b/sql/sql.go index 5b36bc4a..7100b6f2 100644 --- a/sql/sql.go +++ b/sql/sql.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// 2017-11-21 22:32:06.338725044 -0800 PST m=+0.004098353 +// 2017-11-22 12:56:32.152779508 -0800 PST m=+0.004290130 package sql