// Borrowed from the x509 package.
Borrowed from the x509 package.
// Borrowed from the x509 package .
func forEachSAN(extension []byte, callback func(tag int, data []byte) error) error {
	var seq asn1.RawValue
	rest, err := asn1.Unmarshal(extension, &seq)
	if err != nil {
		return err
	} else if len(rest) != 0 {
		return errors.New("x509: trailing data after X.509 extension")
	}
	if !seq.IsCompound || seq.Tag != 16 || seq.Class != 0 {
		return asn1.StructuralError{Msg: "bad SAN sequence"}
	}
	rest = seq.Bytes
	for len(rest) > 0 {
		var v asn1.RawValue
		rest, err = asn1.Unmarshal(rest, &v)
		if err != nil {
			return err
		}
		if err := callback(v.Tag, v.Bytes); err != nil {
			return err
		}
	}
	return nil
}
func forEachSAN ( extension [ ] byte , callback func ( tag int , data [ ] byte ) error ) error { var seq asn1 . RawValue rest , err := asn1 . Unmarshal ( extension , & seq ) if err != nil { return err } else if len ( rest ) != 0 { return errors . New ( " " ) } if ! seq . IsCompound || seq . Tag != 16 || seq . Class != 0 { return asn1 . StructuralError { Msg : " " } } rest = seq . Bytes for len ( rest ) > 0 { var v asn1 . RawValue rest , err = asn1 . Unmarshal ( rest , & v ) if err != nil { return err } if err := callback ( v . Tag , v . Bytes ) ; err != nil { return err } } return nil }
Borrowed from the x509 package.
Borrowed from the x509 package .