@@ -63,13 +63,14 @@ func Read(trustDomain spiffeid.TrustDomain, r io.Reader) (*Bundle, error) {
63
63
// blocks.
64
64
func Parse (trustDomain spiffeid.TrustDomain , b []byte ) (* Bundle , error ) {
65
65
bundle := New (trustDomain )
66
+ if len (b ) == 0 {
67
+ return bundle , nil
68
+ }
69
+
66
70
certs , err := pemutil .ParseCertificates (b )
67
71
if err != nil {
68
72
return nil , x509bundleErr .New ("cannot parse certificate: %v" , err )
69
73
}
70
- if len (certs ) == 0 {
71
- return nil , x509bundleErr .New ("no certificates found" )
72
- }
73
74
for _ , cert := range certs {
74
75
bundle .AddX509Authority (cert )
75
76
}
@@ -80,13 +81,14 @@ func Parse(trustDomain spiffeid.TrustDomain, b []byte) (*Bundle, error) {
80
81
// with no intermediate padding if there are more than one certificate)
81
82
func ParseRaw (trustDomain spiffeid.TrustDomain , b []byte ) (* Bundle , error ) {
82
83
bundle := New (trustDomain )
84
+ if len (b ) == 0 {
85
+ return bundle , nil
86
+ }
87
+
83
88
certs , err := x509 .ParseCertificates (b )
84
89
if err != nil {
85
90
return nil , x509bundleErr .New ("cannot parse certificate: %v" , err )
86
91
}
87
- if len (certs ) == 0 {
88
- return nil , x509bundleErr .New ("no certificates found" )
89
- }
90
92
for _ , cert := range certs {
91
93
bundle .AddX509Authority (cert )
92
94
}
0 commit comments