diff --git a/main.go b/main.go index e6644ffc267f351038fd9da2c882ebd720c98c08..e7acf484e64ba8822a9ff300c07916b69f3c3401 100644 --- a/main.go +++ b/main.go @@ -18,40 +18,30 @@ import ( ) var ( - appVersion string - buildTime string - CertBase string - KeyBase string - GroupName string - RedisBaseURL string - VaultBaseURL string - certificateDestination string - fullchainDestination string - keyDestination string - caDestination string - Type string - tmpCertificateDestination = "/tmp/amce_cert.pem" - tmpFullchainDestination = "/tmp/amce_fullchain.pem" - tmpCaDestination = "/tmp/amce_ca.pem" - tmpKeyDestination = "/tmp/amce_key.pem" - tempCertSlice = []string{tmpCertificateDestination, tmpFullchainDestination, tmpCaDestination, tmpKeyDestination} + appVersion string + buildTime string + CertBase string + KeyBase string + GroupName string + RedisBaseURL string + VaultBaseURL string + certificateDestination string + fullchainDestination string + keyDestination string + caDestination string + Type string ) -// app exit +// app clean and exit func appExit(status int) { - for _, element := range tempCertSlice { - err := os.Remove(element) - if err != nil { - } + err := os.RemoveAll("/tmp/acme-downloader") + if err != nil { } os.Exit(status) } // check certificates func checkCerificates(dnsname string, certificate string, fullchain string, ca string, key string, days int, fail bool) bool { - for _, element := range tempCertSlice { - fmt.Printf(element) - } Seconds := days * 86400 daysNumber := time.Now().Local().Add(time.Second * time.Duration(Seconds)) @@ -328,6 +318,11 @@ Options: fullChain := GetRedisKey(RedisFullChainURL, RedisToken) privKey := GetVaultKey(VaultURL, VaultToken) + // download and test certificates on a temporary location + tmpCertificateDestination := "/tmp/acme-downloader/cert/amce_cert.pem" + tmpFullchainDestination := "/tmp/acme-downloader/cert/amce_fullchain.pem" + tmpCaDestination := "/tmp/acme-downloader/cert/amce_ca.pem" + tmpKeyDestination := "/tmp/acme-downloader/key/amce_key.pem" WriteToFile(certificate, tmpCertificateDestination, GroupName, 0644, 0755) WriteToFile(fullChain, tmpFullchainDestination, GroupName, 0644, 0755) WriteToFile(ca, tmpCaDestination, GroupName, 0644, 0755)