diff options
Diffstat (limited to 'certServiceK8sExternalProvider/src/x509/x509_utils.go')
-rw-r--r-- | certServiceK8sExternalProvider/src/x509/x509_utils.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/certServiceK8sExternalProvider/src/x509/x509_utils.go b/certServiceK8sExternalProvider/src/x509/x509_utils.go index b8b03e1a..b2530132 100644 --- a/certServiceK8sExternalProvider/src/x509/x509_utils.go +++ b/certServiceK8sExternalProvider/src/x509/x509_utils.go @@ -55,3 +55,15 @@ func EncodeX509(cert *x509.Certificate) ([]byte, error) { } return caPem.Bytes(), nil } + +func ParseCertificateArrayToBytes(certificateArray []string) ([]byte, error) { + buffer := bytes.NewBuffer([]byte{}) + for _, cert := range certificateArray { + block, _ := pem.Decode([]byte(cert)) + err := pem.Encode(buffer, &pem.Block{Type: "CERTIFICATE", Bytes: block.Bytes}) + if err != nil { + return nil, err + } + } + return buffer.Bytes(), nil +} |