mirror of
https://github.com/libp2p/go-openssl.git
synced 2025-03-25 13:30:07 +08:00
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:
parent
d9b6402828
commit
6d00a81776
7
pem.go
7
pem.go
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user