From e107e2b87f61ca537c5b9b1baaad3fcaa571a6c3 Mon Sep 17 00:00:00 2001 From: Ricardo Pchevuzinske Katz Date: Mon, 6 Mar 2017 16:33:44 -0300 Subject: [PATCH] Temporary PEM Files cleanup --- core/pkg/net/ssl/ssl.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/pkg/net/ssl/ssl.go b/core/pkg/net/ssl/ssl.go index b007d8bba7..93811ecf36 100644 --- a/core/pkg/net/ssl/ssl.go +++ b/core/pkg/net/ssl/ssl.go @@ -68,11 +68,13 @@ func AddOrUpdateCertAndKey(name string, cert, key, ca []byte) (*ingress.SSLCert, pemCerts, err := ioutil.ReadFile(tempPemFile.Name()) if err != nil { + _ = os.Remove(tempPemFile.Name()) return nil, err } pemBlock, _ := pem.Decode(pemCerts) if pemBlock == nil { + _ = os.Remove(tempPemFile.Name()) return nil, fmt.Errorf("No valid PEM formatted block found") } @@ -84,6 +86,7 @@ func AddOrUpdateCertAndKey(name string, cert, key, ca []byte) (*ingress.SSLCert, pemCert, err := x509.ParseCertificate(pemBlock.Bytes) if err != nil { + _ = os.Remove(tempPemFile.Name()) return nil, err }