Mnemonics
Mnemonics

Reputation: 699

Using wssecurity when consuming a webservice with zeep

So I have been trying to consume a webservice that requires the use of wssecurity. I got a .p12 file that I have divided into two .pem files. One that contains the private key and the other that contains the certification file by using openssl.

Here is the code written in python using the soap-client zeep:

signature = Signature(key_file='C:\key.pem',
                      certfile='C:\cert.pem', password='')
client = Client(wsse=signature,
                  wsdl='test.wsdl',
plugins=[pmhistory])

Building the envelope by using the build in function type_factory I then access the endpoint method with the following code:

returnedMess = client.service.GetInfo(pm_value, _soapheaders={'header':manifest})

When I execute the code I get the following error:

    File "C:\Python27\lib\site-packages\zeep\wsdl\bindings\soap.py", line 95, in _create
    envelope, http_headers)
  File "C:\Python27\lib\site-packages\zeep\wsse\signature.py", line 56, in apply
    key = _make_sign_key(self.key_data, self.cert_data, self.password)
  File "C:\Python27\lib\site-packages\zeep\wsse\signature.py", line 35, in _make_sign_key
    key = xmlsec.Key.from_memory(key_data, xmlsec.KeyFormat.PEM, password)
xmlsec.Error: (1, 'cannot load key')

Does anyone have some information on the returned error? Is a .p12 certification file all I need to sign the envelope with X509 and encrypt the xml body data?

Upvotes: 2

Views: 1331

Answers (0)

Related Questions