aboutsummaryrefslogtreecommitdiffstats
path: root/certServiceK8sExternalProvider/src/x509/x509_utils.go
diff options
context:
space:
mode:
authorTomasz Wrobel <tomasz.wrobel@nokia.com>2020-10-28 16:27:25 +0100
committerTomasz Wrobel <tomasz.wrobel@nokia.com>2020-10-29 15:08:40 +0100
commita622e8871c9bea86aff16ffe5ae021abe08326fe (patch)
tree0bdfad83cae1c39b068f0410ef084b7677381f03 /certServiceK8sExternalProvider/src/x509/x509_utils.go
parent8795295e7783695618ebaa25951b8eb2e35f4333 (diff)
[OOM-K8S-CERT-EXTERNAL-PROVIDER] Save CertService response as PEM artifacts
Issue-ID: OOM-2559 Change-Id: I86ce277396f87fdde5ffafa4ca8f8fe9853daa3c Signed-off-by: Tomasz Wrobel <tomasz.wrobel@nokia.com>
Diffstat (limited to 'certServiceK8sExternalProvider/src/x509/x509_utils.go')
-rw-r--r--certServiceK8sExternalProvider/src/x509/x509_utils.go12
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
+}