From 0e8ddf7f849fe4198fb6d8a06286336b19eb6e83 Mon Sep 17 00:00:00 2001 From: Lukasz Jagiello Date: Thu, 29 Nov 2018 21:47:18 +0100 Subject: [PATCH] Remove an empty line for /pki/ca_chain This PR fix #5778. Easy test case to reproduce the problem: https://play.golang.org/p/CAMdrOHT7C1 Since `certStr` is empty string during first iteration `strings.Join()` will merge empty line with first CA cert. Extra `strings.TrimSpace` call will remove that empty line, before certificate will be return. --- builtin/logical/pki/path_fetch.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/logical/pki/path_fetch.go b/builtin/logical/pki/path_fetch.go index 0bbcff078125..689e4a17e1d0 100644 --- a/builtin/logical/pki/path_fetch.go +++ b/builtin/logical/pki/path_fetch.go @@ -177,7 +177,7 @@ func (b *backend) pathFetchRead(ctx context.Context, req *logical.Request, data } certStr = strings.Join([]string{certStr, strings.TrimSpace(string(pem.EncodeToMemory(&block)))}, "\n") } - certificate = []byte(certStr) + certificate = []byte(strings.TrimSpace(certStr)) goto reply }