From 715cb0beb964726c7f251a98f00db322cf3ce9b6 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 10 Feb 2023 15:16:24 +0100 Subject: [PATCH 1/8] Sligltly simplified getDefaultConfigDir --- config.go | 11 +++++------ main.go | 12 +++++------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/config.go b/config.go index e3225681d..a64278ddb 100644 --- a/config.go +++ b/config.go @@ -17,15 +17,14 @@ package main import ( _ "embed" - "fmt" "os" "github.com/arduino/go-paths-helper" log "github.com/sirupsen/logrus" ) -// getDefaultArduinoCreateConfigDir returns the full path to the default arduino create agent data directory -func getDefaultArduinoCreateConfigDir() (*paths.Path, error) { +// getDefaultConfigDir returns the full path to the default Arduino Create Agent configuration directory. +func getDefaultConfigDir() *paths.Path { // UserConfigDir returns the default root directory to use // for user-specific configuration data. Users should create // their own application-specific subdirectory within this @@ -43,14 +42,14 @@ func getDefaultArduinoCreateConfigDir() (*paths.Path, error) { // is not defined), then it will return an error. configDir, err := os.UserConfigDir() if err != nil { - return nil, err + log.Panicf("Can't get user home dir: %s", err) } agentConfigDir := paths.New(configDir, "ArduinoCreateAgent") if err := agentConfigDir.MkdirAll(); err != nil { - return nil, fmt.Errorf("cannot create config dir: %s", err) + log.Panicf("Can't create config dir: %s", err) } - return agentConfigDir, nil + return agentConfigDir } //go:embed config.ini diff --git a/main.go b/main.go index 723ab7e19..6bbce177c 100755 --- a/main.go +++ b/main.go @@ -136,10 +136,7 @@ func main() { go loop() // SetupSystray is the main thread - configDir, err := getDefaultArduinoCreateConfigDir() - if err != nil { - log.Panicf("Can't open defaul configuration dir: %s", err) - } + configDir := getDefaultConfigDir() Systray = systray.Systray{ Hibernate: *hibernate, Version: version + "-" + commit, @@ -201,7 +198,7 @@ func loop() { src, _ := os.Executable() srcPath := paths.New(src) // The path of the agent's binary srcDir := srcPath.Parent() // The directory of the agent's binary - agentDir, err := getDefaultArduinoCreateConfigDir() + agentDir := getDefaultConfigDir() // Instantiate Tools Tools = tools.Tools{ @@ -216,6 +213,7 @@ func loop() { Tools.Init(requiredToolsAPILevel) // Let's handle the config + configDir := getDefaultConfigDir() var configPath *paths.Path // see if the env var is defined, if it is take the config from there, this will override the default path @@ -225,7 +223,7 @@ func loop() { log.Panicf("config from env var %s does not exists", envConfig) } log.Infof("using config from env variable: %s", configPath) - } else if defaultConfigPath := agentDir.Join("config.ini"); defaultConfigPath.Exist() { + } else if defaultConfigPath := configDir.Join("config.ini"); defaultConfigPath.Exist() { // by default take the config from the ~/.arduino-create/config.ini file configPath = defaultConfigPath log.Infof("using config from default: %s", configPath) @@ -243,7 +241,7 @@ func loop() { } } if configPath == nil { - configPath = generateConfig(agentDir) + configPath = generateConfig(configDir) } // Parse the config.ini From 2d1378980ec54b878026282cdbf61d13415fca3d Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 10 Feb 2023 15:20:14 +0100 Subject: [PATCH 2/8] Some code make-up --- main.go | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/main.go b/main.go index 6bbce177c..0572e8054 100755 --- a/main.go +++ b/main.go @@ -147,25 +147,19 @@ func main() { ConfigDir: configDir, } - path, err := os.Executable() - if err != nil { - panic(err) - } - // If the executable is temporary, copy it to the full path, then restart - if strings.Contains(path, "-temp") { - newPath := updater.BinPath(path) - err := copyExe(path, newPath) - if err != nil { + if src, err := os.Executable(); err != nil { + panic(err) + } else if strings.Contains(src, "-temp") { + newPath := updater.BinPath(src) + if err := copyExe(src, newPath); err != nil { log.Println("Copy error: ", err) panic(err) } - Systray.Update(newPath) } else { // Otherwise copy to a path with -temp suffix - err := copyExe(path, updater.TempPath(path)) - if err != nil { + if err := copyExe(src, updater.TempPath(src)); err != nil { panic(err) } Systray.Start() From 46ff1eab1d1ba4ede7146a1cb669a1f6c0d6073e Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 10 Feb 2023 15:22:06 +0100 Subject: [PATCH 3/8] Added method to directly get data-dir --- config.go | 13 +++++++++++++ main.go | 5 ++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/config.go b/config.go index a64278ddb..fa5ad9cb1 100644 --- a/config.go +++ b/config.go @@ -23,6 +23,19 @@ import ( log "github.com/sirupsen/logrus" ) +// getDataDir returns the full path to the default Arduino Create Agent data directory. +func getDataDir() *paths.Path { + userDir, err := os.UserHomeDir() + if err != nil { + log.Panicf("Could not get user dir: %s", err) + } + dataDir := paths.New(userDir, ".arduino-create") + if err := dataDir.MkdirAll(); err != nil { + log.Panicf("Could not create data dir: %s", err) + } + return dataDir +} + // getDefaultConfigDir returns the full path to the default Arduino Create Agent configuration directory. func getDefaultConfigDir() *paths.Path { // UserConfigDir returns the default root directory to use diff --git a/main.go b/main.go index 0572e8054..8b618af5a 100755 --- a/main.go +++ b/main.go @@ -192,11 +192,10 @@ func loop() { src, _ := os.Executable() srcPath := paths.New(src) // The path of the agent's binary srcDir := srcPath.Parent() // The directory of the agent's binary - agentDir := getDefaultConfigDir() // Instantiate Tools Tools = tools.Tools{ - Directory: agentDir.String(), + Directory: getDataDir().String(), IndexURL: *indexURL, Logger: func(msg string) { mapD := map[string]string{"DownloadStatus": "Pending", "Msg": msg} @@ -407,7 +406,7 @@ func loop() { r.POST("/update", updateHandler) // Mount goa handlers - goa := v2.Server(agentDir.String()) + goa := v2.Server(getDataDir().String()) r.Any("/v2/*path", gin.WrapH(goa)) go func() { From 39387df99279350df004995ef557d9edfb8a3458 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 10 Feb 2023 15:23:06 +0100 Subject: [PATCH 4/8] Added method to directly get logs dir --- config.go | 9 +++++++++ main.go | 5 +---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/config.go b/config.go index fa5ad9cb1..dafba05a1 100644 --- a/config.go +++ b/config.go @@ -36,6 +36,15 @@ func getDataDir() *paths.Path { return dataDir } +// getLogsDir return the directory where logs are saved +func getLogsDir() *paths.Path { + logsDir := getDataDir().Join("logs") + if err := logsDir.MkdirAll(); err != nil { + log.Panicf("Can't create logs dir: %s", err) + } + return logsDir +} + // getDefaultConfigDir returns the full path to the default Arduino Create Agent configuration directory. func getDefaultConfigDir() *paths.Path { // UserConfigDir returns the default root directory to use diff --git a/main.go b/main.go index 8b618af5a..165117468 100755 --- a/main.go +++ b/main.go @@ -343,10 +343,7 @@ func loop() { if *crashreport { logFilename := "crashreport_" + time.Now().Format("20060102150405") + ".log" // handle logs directory creation - logsDir := agentDir.Join("logs") - if logsDir.NotExist() { - logsDir.Mkdir() - } + logsDir := getLogsDir() logFile, err := os.OpenFile(logsDir.Join(logFilename).String(), os.O_WRONLY|os.O_CREATE|os.O_SYNC|os.O_APPEND, 0644) if err != nil { log.Print("Cannot create file used for crash-report") From 1386a7bbbf1a2c7c0c44660820e3408b396cdaa2 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 10 Feb 2023 15:23:36 +0100 Subject: [PATCH 5/8] Removed now useless local variable --- main.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 165117468..9cdc70f84 100755 --- a/main.go +++ b/main.go @@ -188,11 +188,6 @@ func loop() { log.SetLevel(log.InfoLevel) log.SetOutput(os.Stdout) - // the important folders of the agent - src, _ := os.Executable() - srcPath := paths.New(src) // The path of the agent's binary - srcDir := srcPath.Parent() // The directory of the agent's binary - // Instantiate Tools Tools = tools.Tools{ Directory: getDataDir().String(), @@ -221,8 +216,9 @@ func loop() { configPath = defaultConfigPath log.Infof("using config from default: %s", configPath) } else { - // take the config from the old folder where the agent's binary sits - oldConfigPath := srcDir.Join("config.ini") + // Fall back to the old config.ini location + src, _ := os.Executable() + oldConfigPath := paths.New(src).Parent().Join("config.ini") if oldConfigPath.Exist() { err := oldConfigPath.CopyTo(defaultConfigPath) if err != nil { From 82cab46fddf53784f8631db295ffad5f7466cada Mon Sep 17 00:00:00 2001 From: Umberto Baldi Date: Tue, 20 Dec 2022 17:00:56 +0100 Subject: [PATCH 6/8] certs are now created in `.arduino-create` folder --- certificates.go | 53 +++++++++++++++++++++++++++---------------------- config.go | 5 +++++ hub.go | 2 +- main.go | 7 ++++--- 4 files changed, 39 insertions(+), 28 deletions(-) diff --git a/certificates.go b/certificates.go index 4ed0ff02d..895bb66d1 100644 --- a/certificates.go +++ b/certificates.go @@ -24,6 +24,7 @@ import ( "text/template" "time" + "github.com/arduino/go-paths-helper" "github.com/gin-gonic/gin" log "github.com/sirupsen/logrus" ) @@ -133,12 +134,11 @@ func generateSingleCertificate(isCa bool) (*x509.Certificate, error) { return &template, nil } -func generateCertificates() { - - os.Remove("ca.cert.pem") - os.Remove("ca.key.pem") - os.Remove("cert.pem") - os.Remove("key.pem") +func generateCertificates(path *paths.Path) { + path.Join("ca.cert.pem").Remove() + path.Join("ca.key.pem").Remove() + path.Join("cert.pem").Remove() + path.Join("key.pem").Remove() // Create the key for the certification authority caKey, err := generateKey("P256") @@ -146,15 +146,15 @@ func generateCertificates() { log.Error(err.Error()) os.Exit(1) } - - keyOut, err := os.OpenFile("ca.key.pem", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) + keyOutPath := path.Join("ca.key.pem").String() + keyOut, err := os.OpenFile(keyOutPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) if err != nil { log.Error(err.Error()) os.Exit(1) } pem.Encode(keyOut, pemBlockForKey(caKey)) keyOut.Close() - log.Println("written ca.key.pem") + log.Printf("written %s", keyOutPath) // Create the certification authority caTemplate, err := generateSingleCertificate(true) @@ -166,17 +166,19 @@ func generateCertificates() { derBytes, _ := x509.CreateCertificate(rand.Reader, caTemplate, caTemplate, publicKey(caKey), caKey) - certOut, err := os.Create("ca.cert.pem") + certOutPath := path.Join("ca.cert.pem").String() + certOut, err := os.Create(certOutPath) if err != nil { log.Error(err.Error()) os.Exit(1) } pem.Encode(certOut, &pem.Block{Type: "CERTIFICATE", Bytes: derBytes}) certOut.Close() - log.Print("written ca.cert.pem") + log.Printf("written %s", certOutPath) - ioutil.WriteFile("ca.cert.cer", derBytes, 0644) - log.Print("written ca.cert.cer") + filePath := path.Join("ca.cert.cer").String() + ioutil.WriteFile(filePath, derBytes, 0644) + log.Printf("written %s", filePath) // Create the key for the final certificate key, err := generateKey("P256") @@ -185,14 +187,15 @@ func generateCertificates() { os.Exit(1) } - keyOut, err = os.OpenFile("key.pem", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) + keyOutPath = path.Join("key.pem").String() + keyOut, err = os.OpenFile(keyOutPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) if err != nil { log.Error(err.Error()) os.Exit(1) } pem.Encode(keyOut, pemBlockForKey(key)) keyOut.Close() - log.Println("written key.pem") + log.Printf("written %s", keyOutPath) // Create the final certificate template, err := generateSingleCertificate(false) @@ -204,17 +207,19 @@ func generateCertificates() { derBytes, _ = x509.CreateCertificate(rand.Reader, template, caTemplate, publicKey(key), caKey) - certOut, err = os.Create("cert.pem") + certOutPath = path.Join("cert.pem").String() + certOut, err = os.Create(certOutPath) if err != nil { log.Error(err.Error()) os.Exit(1) } pem.Encode(certOut, &pem.Block{Type: "CERTIFICATE", Bytes: derBytes}) certOut.Close() - log.Print("written cert.pem") + log.Printf("written %s", certOutPath) - ioutil.WriteFile("cert.cer", derBytes, 0644) - log.Print("written cert.cer") + certPath := path.Join("cert.cer").String() + ioutil.WriteFile(certPath, derBytes, 0644) + log.Printf("written %s", certPath) } @@ -230,14 +235,14 @@ func certHandler(c *gin.Context) { } func deleteCertHandler(c *gin.Context) { - DeleteCertificates() + DeleteCertificates(getCertificatesDir()) } // DeleteCertificates will delete the certificates -func DeleteCertificates() { - os.Remove("ca.cert.pem") - os.Remove("ca.cert.cer") - os.Remove("ca.key.pem") +func DeleteCertificates(path *paths.Path) { + path.Join("ca.cert.pem").Remove() + path.Join("ca.cert.cer").Remove() + path.Join("ca.key.pem").Remove() } const noFirefoxTemplateHTML = ` diff --git a/config.go b/config.go index dafba05a1..182e24c52 100644 --- a/config.go +++ b/config.go @@ -23,6 +23,11 @@ import ( log "github.com/sirupsen/logrus" ) +// getCertificatesDir return the directory where SSL certificates are saved +func getCertificatesDir() *paths.Path { + return getDataDir() +} + // getDataDir returns the full path to the default Arduino Create Agent data directory. func getDataDir() *paths.Path { userDir, err := os.UserHomeDir() diff --git a/hub.go b/hub.go index 205c00d34..f59c6460e 100755 --- a/hub.go +++ b/hub.go @@ -182,7 +182,7 @@ func checkCmd(m []byte) { } else if strings.HasPrefix(sl, "downloadtool") { // Always delete root certificates when we receive a downloadtool command // Useful if the install procedure was not followed strictly (eg. manually) - DeleteCertificates() + DeleteCertificates(getCertificatesDir()) go func() { args := strings.Split(s, " ") var tool, toolVersion, pack, behaviour string diff --git a/main.go b/main.go index 9cdc70f84..4d8fcf45c 100755 --- a/main.go +++ b/main.go @@ -128,7 +128,7 @@ func main() { // Generate certificates if *genCert { - generateCertificates() + generateCertificates(getCertificatesDir()) os.Exit(0) } @@ -404,7 +404,8 @@ func loop() { go func() { // check if certificates exist; if not, use plain http - if srcDir.Join("cert.pem").NotExist() { + certsDir := getCertificatesDir() + if certsDir.Join("cert.pem").NotExist() { log.Error("Could not find HTTPS certificate. Using plain HTTP only.") return } @@ -415,7 +416,7 @@ func loop() { for i < end { i = i + 1 portSSL = ":" + strconv.Itoa(i) - if err := r.RunTLS(*address+portSSL, srcDir.Join("cert.pem").String(), srcDir.Join("key.pem").String()); err != nil { + if err := r.RunTLS(*address+portSSL, certsDir.Join("cert.pem").String(), certsDir.Join("key.pem").String()); err != nil { log.Printf("Error trying to bind to port: %v, so exiting...", err) continue } else { From 1dab6b40363aa8e4a8bfd2562a09d30a2509f22e Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 10 Feb 2023 16:53:45 +0100 Subject: [PATCH 7/8] Better use of go-paths library --- certificates.go | 111 ++++++++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 51 deletions(-) diff --git a/certificates.go b/certificates.go index 895bb66d1..0204265e5 100644 --- a/certificates.go +++ b/certificates.go @@ -16,7 +16,6 @@ import ( "crypto/x509/pkix" "encoding/pem" "fmt" - "io/ioutil" "math/big" "net" "os" @@ -134,11 +133,11 @@ func generateSingleCertificate(isCa bool) (*x509.Certificate, error) { return &template, nil } -func generateCertificates(path *paths.Path) { - path.Join("ca.cert.pem").Remove() - path.Join("ca.key.pem").Remove() - path.Join("cert.pem").Remove() - path.Join("key.pem").Remove() +func generateCertificates(certsDir *paths.Path) { + certsDir.Join("ca.cert.pem").Remove() + certsDir.Join("ca.key.pem").Remove() + certsDir.Join("cert.pem").Remove() + certsDir.Join("key.pem").Remove() // Create the key for the certification authority caKey, err := generateKey("P256") @@ -146,19 +145,21 @@ func generateCertificates(path *paths.Path) { log.Error(err.Error()) os.Exit(1) } - keyOutPath := path.Join("ca.key.pem").String() - keyOut, err := os.OpenFile(keyOutPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) - if err != nil { - log.Error(err.Error()) - os.Exit(1) + + { + keyOutPath := certsDir.Join("ca.key.pem").String() + keyOut, err := os.OpenFile(keyOutPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) // Save key with user-only permission 0600 + if err != nil { + log.Error(err.Error()) + os.Exit(1) + } + pem.Encode(keyOut, pemBlockForKey(caKey)) + keyOut.Close() + log.Printf("written %s", keyOutPath) } - pem.Encode(keyOut, pemBlockForKey(caKey)) - keyOut.Close() - log.Printf("written %s", keyOutPath) // Create the certification authority caTemplate, err := generateSingleCertificate(true) - if err != nil { log.Error(err.Error()) os.Exit(1) @@ -166,19 +167,23 @@ func generateCertificates(path *paths.Path) { derBytes, _ := x509.CreateCertificate(rand.Reader, caTemplate, caTemplate, publicKey(caKey), caKey) - certOutPath := path.Join("ca.cert.pem").String() - certOut, err := os.Create(certOutPath) - if err != nil { - log.Error(err.Error()) - os.Exit(1) + { + caCertOutPath := certsDir.Join("ca.cert.pem") + caCertOut, err := caCertOutPath.Create() + if err != nil { + log.Error(err.Error()) + os.Exit(1) + } + pem.Encode(caCertOut, &pem.Block{Type: "CERTIFICATE", Bytes: derBytes}) + caCertOut.Close() + log.Printf("written %s", caCertOutPath) } - pem.Encode(certOut, &pem.Block{Type: "CERTIFICATE", Bytes: derBytes}) - certOut.Close() - log.Printf("written %s", certOutPath) - filePath := path.Join("ca.cert.cer").String() - ioutil.WriteFile(filePath, derBytes, 0644) - log.Printf("written %s", filePath) + { + caCertPath := certsDir.Join("ca.cert.cer") + caCertPath.WriteFile(derBytes) + log.Printf("written %s", caCertPath) + } // Create the key for the final certificate key, err := generateKey("P256") @@ -187,19 +192,20 @@ func generateCertificates(path *paths.Path) { os.Exit(1) } - keyOutPath = path.Join("key.pem").String() - keyOut, err = os.OpenFile(keyOutPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) - if err != nil { - log.Error(err.Error()) - os.Exit(1) + { + keyOutPath := certsDir.Join("key.pem").String() + keyOut, err := os.OpenFile(keyOutPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) // Save key with user-only permission 0600 + if err != nil { + log.Error(err.Error()) + os.Exit(1) + } + pem.Encode(keyOut, pemBlockForKey(key)) + keyOut.Close() + log.Printf("written %s", keyOutPath) } - pem.Encode(keyOut, pemBlockForKey(key)) - keyOut.Close() - log.Printf("written %s", keyOutPath) // Create the final certificate template, err := generateSingleCertificate(false) - if err != nil { log.Error(err.Error()) os.Exit(1) @@ -207,20 +213,23 @@ func generateCertificates(path *paths.Path) { derBytes, _ = x509.CreateCertificate(rand.Reader, template, caTemplate, publicKey(key), caKey) - certOutPath = path.Join("cert.pem").String() - certOut, err = os.Create(certOutPath) - if err != nil { - log.Error(err.Error()) - os.Exit(1) + { + certOutPath := certsDir.Join("cert.pem").String() + certOut, err := os.Create(certOutPath) + if err != nil { + log.Error(err.Error()) + os.Exit(1) + } + pem.Encode(certOut, &pem.Block{Type: "CERTIFICATE", Bytes: derBytes}) + certOut.Close() + log.Printf("written %s", certOutPath) } - pem.Encode(certOut, &pem.Block{Type: "CERTIFICATE", Bytes: derBytes}) - certOut.Close() - log.Printf("written %s", certOutPath) - - certPath := path.Join("cert.cer").String() - ioutil.WriteFile(certPath, derBytes, 0644) - log.Printf("written %s", certPath) + { + certPath := certsDir.Join("cert.cer") + certPath.WriteFile(derBytes) + log.Printf("written %s", certPath) + } } func certHandler(c *gin.Context) { @@ -239,10 +248,10 @@ func deleteCertHandler(c *gin.Context) { } // DeleteCertificates will delete the certificates -func DeleteCertificates(path *paths.Path) { - path.Join("ca.cert.pem").Remove() - path.Join("ca.cert.cer").Remove() - path.Join("ca.key.pem").Remove() +func DeleteCertificates(certDir *paths.Path) { + certDir.Join("ca.cert.pem").Remove() + certDir.Join("ca.cert.cer").Remove() + certDir.Join("ca.key.pem").Remove() } const noFirefoxTemplateHTML = ` From 1d0d5de4b7483515155e11a0f6e27facea421eba Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 10 Feb 2023 17:07:32 +0100 Subject: [PATCH 8/8] Perform certificates migration if needed --- certificates.go | 27 +++++++++++++++++++++++++++ main.go | 2 ++ 2 files changed, 29 insertions(+) diff --git a/certificates.go b/certificates.go index 0204265e5..af8f6c3a2 100644 --- a/certificates.go +++ b/certificates.go @@ -133,6 +133,33 @@ func generateSingleCertificate(isCa bool) (*x509.Certificate, error) { return &template, nil } +// migrateCertificatesGeneratedWithOldAgentVersions checks if certificates generated +// with an old version of the Agent needs to be migrated to the current certificates +// directory, and performs the migration if needed. +func migrateCertificatesGeneratedWithOldAgentVersions(certsDir *paths.Path) { + if certsDir.Join("ca.cert.pem").Exist() { + // The new certificates are already set-up, nothing to do + return + } + + fileList := []string{ + "ca.key.pem", + "ca.cert.pem", + "ca.cert.cer", + "key.pem", + "cert.pem", + "cert.cer", + } + oldCertsDirPath, _ := os.Executable() + oldCertsDir := paths.New(oldCertsDirPath) + for _, fileName := range fileList { + oldCert := oldCertsDir.Join(fileName) + if oldCert.Exist() { + oldCert.CopyTo(certsDir.Join(fileName)) + } + } +} + func generateCertificates(certsDir *paths.Path) { certsDir.Join("ca.cert.pem").Remove() certsDir.Join("ca.key.pem").Remove() diff --git a/main.go b/main.go index 4d8fcf45c..943cfdf79 100755 --- a/main.go +++ b/main.go @@ -131,6 +131,8 @@ func main() { generateCertificates(getCertificatesDir()) os.Exit(0) } + // Check if certificates made with Agent <=1.2.7 needs to be moved over the new location + migrateCertificatesGeneratedWithOldAgentVersions(getCertificatesDir()) // Launch main loop in a goroutine go loop()