Skip to content

Commit

Permalink
removes pem header/footer before b64 decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
arlotito committed Apr 28, 2021
1 parent 3315883 commit 502dbf8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"io"
"io/ioutil"
"reflect"
"strings"

"github.com/google/go-tpm/tpm2"
"go.mozilla.org/pkcs7"
Expand Down Expand Up @@ -154,7 +155,18 @@ func readAllBase64Request(r io.Reader) ([]byte, error) {
return nil, errInternal
}

// arlotito ---------------------------
// removes header/footer if there
s := string(b[:])
s = strings.Replace(s, "-----BEGIN CERTIFICATE REQUEST-----", "", -1)
s = strings.Replace(s, "-----END CERTIFICATE REQUEST-----", "", -1)

// convert back to binary buffer for base64 decoding
b = []byte(s)
// ------------------------------------

decoded, err := base64Decode(b)

if err != nil {
return nil, errInvalidBase64
}
Expand Down

0 comments on commit 502dbf8

Please sign in to comment.