diff --git a/cmd/stdiscosrv/main.go b/cmd/stdiscosrv/main.go index 8224b1b96..f87c668dc 100644 --- a/cmd/stdiscosrv/main.go +++ b/cmd/stdiscosrv/main.go @@ -98,14 +98,15 @@ func main() { } cert, err := tls.LoadX509KeyPair(certFile, keyFile) - if err != nil { + if os.IsNotExist(err) { log.Println("Failed to load keypair. Generating one, this might take a while...") cert, err = tlsutil.NewCertificate(certFile, keyFile, "stdiscosrv", 20*365) if err != nil { log.Fatalln("Failed to generate X509 key pair:", err) } + } else if err != nil { + log.Fatalln("Failed to load keypair:", err) } - devID := protocol.NewDeviceID(cert.Certificate[0]) log.Println("Server device ID is", devID)