Using XML-DSig (XML Digital Signature) and OpenSSL from Python scripts is not straightforward, but there are solutions. Here are a few links to useful libraries and articles.
Of course if you know other useful libraries and documentation, please leave a comment below or e-mail me at decalage(à)laposte.net.