aboutsummaryrefslogtreecommitdiff
path: root/pem.go
diff options
context:
space:
mode:
authorGibheer <gibheer+git@zero-knowledge.org>2018-04-18 16:01:57 +0200
committerGibheer <gibheer+git@zero-knowledge.org>2018-04-18 16:01:57 +0200
commit083e8c2ce4ee8ed250d1e38bd115717733f0a324 (patch)
tree0ce911e0f8dad5bcc9f686e6dd920ded42bcbe65 /pem.go
parente9cd735e0c85c36ad05b540e287463235b49eebe (diff)
fix error when no pem label is found
Diffstat (limited to 'pem.go')
-rw-r--r--pem.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/pem.go b/pem.go
index d3956f6..bbe2a47 100644
--- a/pem.go
+++ b/pem.go
@@ -20,13 +20,13 @@ type (
// To get this working, the section must only be contained one time and nothing
// but the wanted section must exist.
func getSectionFromPem(pems pemMap, label string) ([]byte, error) {
- if len(pems) > 1 {
- return []byte{}, fmt.Errorf("too many entries in sign request file")
+ if res, found := pems[label]; !found {
+ return []byte{}, fmt.Errorf("could not find section '%s'", label)
+ } else if len(res) > 1 {
+ return []byte{}, fmt.Errorf("too many entries of type '%s'", label)
+ } else {
+ return res[0], nil
}
- if len(pems[label]) > 1 {
- return []byte{}, fmt.Errorf("too many sign requests found in file")
- }
- return pems[label][0], nil
}
// parse the content of a file into a map of pem decoded bodies