How to connect to a SOAP service (without WSDL) using SSL and authentication in Python? -


i want connect soap api not have wsdl in python. connect need add ssl certificate , authenticate afterwards.

from pysimplesoap.client import soapclient, simplexmlelement  cacert = open(path, 'rb').read()  # read certificate header = simplexmlelement('<header/>') credentials = header.add_child('credentials') credentials.marshall('password', 'password') credentials.marshall('username', 'username')  client = soapclient(     location="https://mytest.com/services/",     cacert=cacert) client['header'] = header  client.action = "https://mytest.com/services/action1"  client.action1()  # gives ssl error 

the result receive ssl error:

sslhandshakeerror: [errno 1] _ssl.c:510: error:14090086:ssl routines:ssl3_get_server_certificate:certificate verify failed 

can anyone, please, tell me how solve issue? or can advise other library can use. soap libraries found offer connection wsdl.

usually in pfx file there client certificate key, not ca file. libraries seems expect client certificate pem. should extract certificate , key show in https://stackoverflow.com/a/9516936/3929826.

then hand in soapclient() initiation cert , key_file argument:

client = soapclient(location="https://mytest.com/services/",                     cert='mycert.pem',                     key_file='mycert.key) 

it should possible put both cert file.

if still not work have add ca certificate cacert parameter after retrieved described in https://stackoverflow.com/a/7886248/3929826 .

for further reference see source code of simplesoap: https://code.google.com/p/pysimplesoap/source/browse/pysimplesoap/client.py#75 .


Comments