Skip to content

Commit 9ce6dfd

Browse files
committed
Refactor CryptoBackendXmlSec1::sign_statement
Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent cb760c8 commit 9ce6dfd

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/saml2/sigver.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -835,19 +835,16 @@ def sign_statement(self, statement, node_name, key_file, node_id, id_attr):
835835
com_list.extend(['--node-id', node_id])
836836

837837
try:
838-
(stdout, stderr, signed_statement) = self._run_xmlsec(
839-
com_list, [fil]
840-
)
841-
842-
# this doesn't work if --store-signatures are used
843-
if stdout == '':
844-
if signed_statement:
845-
return signed_statement.decode('utf-8')
846-
847-
logger.error('Signing operation failed :\nstdout : %s\nstderr : %s', stdout, stderr)
848-
raise SigverError(stderr)
849-
except DecryptError:
850-
raise SigverError('Signing failed')
838+
(stdout, stderr, output) = self._run_xmlsec(com_list, [fil])
839+
except XmlsecError as e:
840+
raise SignatureError(com_list)
841+
842+
# this does not work if --store-signatures is used
843+
if output:
844+
return output.decode("utf-8")
845+
if stdout:
846+
return stdout.decode("utf-8")
847+
raise SignatureError(stderr)
851848

852849
def validate_signature(self, signedtext, cert_file, cert_type, node_name, node_id, id_attr):
853850
"""

0 commit comments

Comments
 (0)