Hi everyone,
I got an error in this class while using jira rest api authentication, until now it worked well; but today i got an error.
class SignatureMethod_RSA_SHA1(oauth.SignatureMethod):
name = 'RSA-SHA1'
def signing_base(self, request, consumer, token):
if not hasattr(request, 'normalized_url') or request.normalized_url is None:
raise ValueError("Base URL for request is not set.")
sig = (
oauth.escape(request.method),
oauth.escape(request.normalized_url),
oauth.escape(request.get_normalized_parameters()),
)
key = '%s&' % oauth.escape(consumer.secret)
if token:
key += oauth.escape(token.secret)
raw = '&'.join(sig)
return key, raw
def sign(self, request, consumer, token):
"""Builds the base signature string."""
key, raw = self.signing_base(request, consumer, token)
with open('***.pem', 'r') as f:
data = f.read()
privateKeyString = data.strip()
privatekey = keyfactory.parsePrivateKey(privateKeyString)
signature = privatekey.hashAndSign(raw)
return base64.b64encode(signature)
The error:
File "***/utils.py", line 84, in getJson
r = client.request(url, "GET")
File "/usr/local/lib/python2.7/dist-packages/oauth2/__init__.py", line 673, in request
req.sign_request(self.method, self.consumer, self.token)
File "/usr/local/lib/python2.7/dist-packages/oauth2/__init__.py", line 502, in sign_request
self['oauth_signature'] = signature_method.sign(self, consumer, token)
File "/mnt/c/Users/asadiya/Repository/jira-bamboo-reports/utils.py", line 53, in sign
signature = privatekey.hashAndSign(raw)
File "/usr/local/lib/python2.7/dist-packages/tlslite/utils/rsakey.py", line 64, in hashAndSign
sigBytes = self.sign(prefixedHashBytes)
File "/usr/local/lib/python2.7/dist-packages/tlslite/utils/rsakey.py", line 108, in sign
c = self._rawPrivateKeyOp(m)
File "/usr/local/lib/python2.7/dist-packages/tlslite/utils/pycrypto_rsakey.py", line 32, in _rawPrivateKeyOp
c = self.rsa.decrypt((m,))
File "/usr/local/lib/python2.7/dist-packages/Crypto/PublicKey/RSA.py", line 378, in decrypt
raise NotImplementedError("Use module Crypto.Cipher.PKCS1_OAEP instead")
NotImplementedError: Use module Crypto.Cipher.PKCS1_OAEP instead
Any suggestion to fix this error?
Thanks.