Skip to content

Commit

Permalink
Temporary PEM Files cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricardo Pchevuzinske Katz committed Mar 6, 2017
1 parent 51235a3 commit e107e2b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/pkg/net/ssl/ssl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand All @@ -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
}

Expand Down

0 comments on commit e107e2b

Please sign in to comment.