File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
Filter options
Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
Original file line number Diff line number Diff line change @@ -96,3 +96,12 @@ func LoadCertificatesFromFile(certificateFile *paths.Path) ([]*x509.Certificate,
96
96
return nil , fmt .Errorf ("cert format %s not supported, please use .pem or .cer" , certificateFile .Ext ())
97
97
}
98
98
}
99
+
100
+ // EncodeCertificateAsPEM returns the PEM encoding of the given certificate
101
+ func EncodeCertificateAsPEM (cert * x509.Certificate ) []byte {
102
+ pemBlock := & pem.Block {
103
+ Type : "CERTIFICATE" ,
104
+ Bytes : cert .Raw ,
105
+ }
106
+ return pem .EncodeToMemory (pemBlock )
107
+ }
Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ import (
22
22
"bytes"
23
23
"crypto/md5"
24
24
"encoding/binary"
25
- "encoding/pem"
26
25
"fmt"
27
26
"io"
28
27
"time"
@@ -106,7 +105,7 @@ func (f *NinaFlasher) FlashCertificates(certificatePaths *paths.PathList, URLs [
106
105
return err
107
106
}
108
107
for _ , cert := range certs {
109
- data := pem . EncodeToMemory ( & pem. Block { Type : "CERTIFICATE" , Bytes : cert . Raw } )
108
+ data := certificates . EncodeCertificateAsPEM ( cert )
110
109
certificatesData = append (certificatesData , data ... )
111
110
}
112
111
}
@@ -118,7 +117,7 @@ func (f *NinaFlasher) FlashCertificates(certificatePaths *paths.PathList, URLs [
118
117
if err != nil {
119
118
return err
120
119
}
121
- data := pem . EncodeToMemory ( & pem. Block { Type : "CERTIFICATE" , Bytes : rootCertificate . Raw } )
120
+ data := certificates . EncodeCertificateAsPEM ( rootCertificate )
122
121
certificatesData = append (certificatesData , data ... )
123
122
}
124
123
You can’t perform that action at this time.
0 commit comments