2

I have to sign a soap request using .JKS key in python but since i couldn't find any way to do that I turned the format into .PEM and then used zeep to send the request:

    signature = Signature('client.key.pem', 'client.crt.pem')
    self.client = Client(
        self.wsdl_url,
        wsse=signature)
    print(self.client.service.Login())

but when i try to see if the verification was successful by calling the Login service I get the error:

  File "/home/setareh/job/backend/TTopApp/V4/thirdParty/bank/paya/mellat_paya.py", line 17, in __init__
    print(self.client.service.Login())
  File "/home/setareh/job/venv/lib/python3.8/site-packages/zeep/proxy.py", line 46, in __call__
    return self._proxy._binding.send(
  File "/home/setareh/job/venv/lib/python3.8/site-packages/zeep/wsdl/bindings/soap.py", line 135, in send
    return self.process_reply(client, operation_obj, response)
  File "/home/setareh/job/venv/lib/python3.8/site-packages/zeep/wsdl/bindings/soap.py", line 219, in process_reply
    client.wsse.verify(doc)
  File "/home/setareh/job/venv/lib/python3.8/site-packages/zeep/wsse/signature.py", line 74, in verify
    _verify_envelope_with_key(envelope, key)
  File "/home/setareh/job/venv/lib/python3.8/site-packages/zeep/wsse/signature.py", line 311, in _verify_envelope_with_key
    raise SignatureVerificationFailed()
zeep.exceptions.SignatureVerificationFailed

What am i doing wrong? Is it even possible to sign using a different format? Because i didn't find any way to sign using the original jks format.

1 Answers1

0

Try this

from requests import Session
from zeep import Client
from zeep.transports import Transport

session = Session()
session.cert = "path/to/.pem/file", "path/to/.key/file"
Client("this is my link", transport=Transport(session=session))
Duma
  • 124
  • 2
  • 12