diff --git a/pkg/api/ca.go b/pkg/api/ca.go index c677a1770..605106592 100644 --- a/pkg/api/ca.go +++ b/pkg/api/ca.go @@ -16,6 +16,7 @@ package api import ( + "bytes" "context" "crypto" "crypto/x509" @@ -202,7 +203,7 @@ func (a *api) signingCert(w http.ResponseWriter, req *http.Request) { return } fmt.Fprintf(&ret, "%s", finalPEM) - if finalPEM[len(finalPEM)-1] != '\n' { + if !bytes.HasSuffix(finalPEM, []byte("\n")) { fmt.Fprintf(&ret, "\n") } @@ -213,7 +214,7 @@ func (a *api) signingCert(w http.ResponseWriter, req *http.Request) { } if len(finalChainPEM) > 0 { fmt.Fprintf(&ret, "%s", finalChainPEM) - if finalPEM[len(finalChainPEM)-1] != '\n' { + if !bytes.HasSuffix(finalChainPEM, []byte("\n")) { fmt.Fprintf(&ret, "\n") } }