Enabled PEM files with CRLF line endings to be used (#10); made PEM file splitter tolerant of trailing whitespace in PEM block delimiter lines

This commit is contained in:
Stephan Eberle 2020-10-01 20:09:41 +02:00
parent d9b6402828
commit 6d00a81776

7
pem.go
View File

@ -16,13 +16,14 @@ package openssl
import (
"regexp"
)
var pemSplit *regexp.Regexp = regexp.MustCompile(`(?sm)` +
`(^-----[\s-]*?BEGIN.*?-----$` +
`(^-----[\s-]*?BEGIN.*?-----[\s-]*?$` +
`.*?` +
`^-----[\s-]*?END.*?-----$)`)
`^-----[\s-]*?END.*?-----[\s-]*?$)`)
func SplitPEM(data []byte) [][]byte {
var results [][]byte
for _, block := range pemSplit.FindAll(data, -1) {