Skip to content

Commit 2c6758b

Browse files
author
Michael Davis
committed
Merge pull request #11 from mpdavis/9-incorrect-error-message
Handle signature verification faliures
2 parents 30d07a6 + 2200ecc commit 2c6758b

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

jose/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ class JWSError(JOSEError):
88
pass
99

1010

11+
class JWSSignatureError(JWSError):
12+
pass
13+
14+
1115
class JWSAlgorithmError(JWSError):
1216
pass
1317

jose/jws.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from jose.jwk import get_algorithm_object
99
from jose.constants import ALGORITHMS
1010
from jose.exceptions import JWSError
11+
from jose.exceptions import JWSSignatureError
1112
from jose.utils import base64url_encode
1213
from jose.utils import base64url_decode
1314

@@ -203,7 +204,9 @@ def _verify_signature(payload, signing_input, header, signature, key='', algorit
203204
key = alg_obj.prepare_key(key)
204205

205206
if not alg_obj.verify(signing_input, key, signature):
206-
raise JWSError('Signature verification failed')
207+
raise JWSSignatureError()
207208

209+
except JWSSignatureError:
210+
raise JWSError('Signature verification failed.')
208211
except JWSError:
209212
raise JWSError('Invalid or unsupported algorithm: %s' % alg)

0 commit comments

Comments
 (0)