@@ -234,16 +234,17 @@ func (ctx *ValidationContext) verifySignedInfo(sig *types.Signature, canonicaliz
234
234
}
235
235
236
236
func (ctx * ValidationContext ) validateSignature (el * etree.Element , sig * types.Signature , cert * x509.Certificate ) (* etree.Element , error ) {
237
- idAttr := el .SelectAttr (ctx .IdAttribute )
238
- if idAttr == nil || idAttr .Value == "" {
239
- return nil , errors .New ("Missing ID attribute" )
237
+ idAttrEl := el .SelectAttr (ctx .IdAttribute )
238
+ idAttr := ""
239
+ if idAttrEl != nil {
240
+ idAttr = idAttrEl .Value
240
241
}
241
242
242
243
var ref * types.Reference
243
244
244
245
// Find the first reference which references the top-level element
245
246
for _ , _ref := range sig .SignedInfo .References {
246
- if _ref .URI == "" || _ref .URI [1 :] == idAttr . Value {
247
+ if _ref .URI == "" || _ref .URI [1 :] == idAttr {
247
248
ref = & _ref
248
249
}
249
250
}
@@ -318,9 +319,10 @@ func validateShape(signatureEl *etree.Element) error {
318
319
319
320
// findSignature searches for a Signature element referencing the passed root element.
320
321
func (ctx * ValidationContext ) findSignature (root * etree.Element ) (* types.Signature , error ) {
321
- idAttr := root .SelectAttr (ctx .IdAttribute )
322
- if idAttr == nil || idAttr .Value == "" {
323
- return nil , errors .New ("Missing ID attribute" )
322
+ idAttrEl := root .SelectAttr (ctx .IdAttribute )
323
+ idAttr := ""
324
+ if idAttrEl != nil {
325
+ idAttr = idAttrEl .Value
324
326
}
325
327
326
328
var sig * types.Signature
@@ -403,7 +405,7 @@ func (ctx *ValidationContext) findSignature(root *etree.Element) (*types.Signatu
403
405
// Traverse references in the signature to determine whether it has at least
404
406
// one reference to the top level element. If so, conclude the search.
405
407
for _ , ref := range _sig .SignedInfo .References {
406
- if ref .URI == "" || ref .URI [1 :] == idAttr . Value {
408
+ if ref .URI == "" || ref .URI [1 :] == idAttr {
407
409
sig = _sig
408
410
return etreeutils .ErrTraversalHalted
409
411
}
0 commit comments