Initial fork + ported fix from https://github.com/rohe/pysaml2/commit/61a301e3bcc987d74c036826afba1bfe2ffddf1c