From 775ed4d0ad0e8b61b5b8b5ea9e045029596bd282 Mon Sep 17 00:00:00 2001 From: Hariharan Subramanian Date: Mon, 8 Oct 2018 02:51:37 -0700 Subject: [PATCH] STL-1313 - Post batch with Signer Public Key as string is not responding Signing module secp256k1.py updated with returning to value after Parse error exception is raised. This prevents client hanging issue when client supplies bad signer key value. Signed-off-by: Hariharan Subramanian --- signing/sawtooth_signing/secp256k1.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/signing/sawtooth_signing/secp256k1.py b/signing/sawtooth_signing/secp256k1.py index 6021b46e56..8174b714b0 100644 --- a/signing/sawtooth_signing/secp256k1.py +++ b/signing/sawtooth_signing/secp256k1.py @@ -81,14 +81,19 @@ def as_bytes(self): @staticmethod def from_hex(hex_str): + parse_exception = True try: public_key = __PK__.deserialize(binascii.unhexlify(hex_str)) - - return Secp256k1PublicKey( - secp256k1.PublicKey(public_key, ctx=__CTX__)) except Exception as e: + parse_exception = True raise ParseError('Unable to parse public key: {}'.format(e)) - + else: + parse_exception = False + return Secp256k1PublicKey( + secp256k1.PublicKey(public_key, ctx=__CTX__)) + finally: + if parse_exception is True: + return Secp256k1PublicKey(secp256k1.PublicKey()) class Secp256k1Context(Context): def __init__(self):