From 81f683a61c0117fd5cd002d140d6f9d8f027368f Mon Sep 17 00:00:00 2001 From: Audrius Butkevicius Date: Tue, 23 Aug 2016 08:41:49 +0200 Subject: [PATCH] cmd/stdiscosrv: Generate keys if missing on startup (fixes #3511) --- cmd/stdiscosrv/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/stdiscosrv/main.go b/cmd/stdiscosrv/main.go index ff5af59f1..bbbf7c996 100644 --- a/cmd/stdiscosrv/main.go +++ b/cmd/stdiscosrv/main.go @@ -14,6 +14,7 @@ import ( "time" "github.com/syncthing/syncthing/lib/protocol" + "github.com/syncthing/syncthing/lib/tlsutil" "github.com/thejerf/suture" ) @@ -86,7 +87,11 @@ func main() { if !useHTTP { cert, err = tls.LoadX509KeyPair(certFile, keyFile) if err != nil { - log.Fatalln("Failed to load X509 key pair:", err) + log.Println("Failed to load keypair. Generating one, this might take a while...") + cert, err = tlsutil.NewCertificate(certFile, keyFile, "stdiscosrv", 3072) + if err != nil { + log.Fatalln("Failed to generate X509 key pair:", err) + } } devID := protocol.NewDeviceID(cert.Certificate[0])