summaryrefslogtreecommitdiff
path: root/jwt/algorithms.py
diff options
context:
space:
mode:
Diffstat (limited to 'jwt/algorithms.py')
-rw-r--r--jwt/algorithms.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/jwt/algorithms.py b/jwt/algorithms.py
index f539b5e..b22a1d9 100644
--- a/jwt/algorithms.py
+++ b/jwt/algorithms.py
@@ -103,7 +103,13 @@ class HMACAlgorithm(Algorithm):
if isinstance(key, text_type):
key = key.encode('utf-8')
- if (b'-----BEGIN PUBLIC KEY-----' in key or b'-----BEGIN CERTIFICATE-----' in key):
+ invalid_strings = [
+ b'-----BEGIN PUBLIC KEY-----',
+ b'-----BEGIN CERTIFICATE-----',
+ b'ssh-rsa'
+ ]
+
+ if any([string_value in key for string_value in invalid_strings]):
raise InvalidKeyError(
'The specified key is an assymetric key or x509 certificate and'
' should not be used as an HMAC secret.')