Don't use JAXB to 'clean up' the XML. It does indeed make the XML cleaner, but it potentially messes up the signed elements. Indeed, I'm pretty sure it messed up the SigningTime timestamp (reset timezone to local), which would break the signature. Also removed the centralized Jaxb class which would put to many namespaces on elements.