diff --git a/verify.go b/verify.go index 4fdef78..e1fed88 100644 --- a/verify.go +++ b/verify.go @@ -350,6 +350,14 @@ func getCertFromCertsByIssuerAndSerial(certs []*x509.Certificate, ias issuerAndS return nil } +type AttributeNotFoundError struct { + AttributeType asn1.ObjectIdentifier +} + +func (a AttributeNotFoundError) Error() string { + return fmt.Sprintf("pkcs7: attribute %s does not exist", a.AttributeType) +} + func unmarshalAttribute(attrs []attribute, attributeType asn1.ObjectIdentifier, out interface{}) error { for _, attr := range attrs { if attr.Type.Equal(attributeType) { @@ -357,5 +365,5 @@ func unmarshalAttribute(attrs []attribute, attributeType asn1.ObjectIdentifier, return err } } - return errors.New("pkcs7: attribute type not in attributes") + return AttributeNotFoundError{AttributeType: attributeType} }