Solved, thanks to Thomas Pornin.
I'm using the org.apache.xml.security.c14n.Canonicalizer for the canonicalization of the SignedInfo element, but the resulting string needs to be further handled:
- Remove all the leading spaces on each line;
- Get an hexadecimal representation of the string above and make sure that all end-of-lines use a single LF (0A).