A suds
client uses a subclass of suds.transport.Transport
to process requests.
The default transport used is an instance of suds.transport.https.HttpAuthenticated
, but you can override this when you instantiate the client by passing a transport
keyword argument.
The http and https transports are implemented using urllib.request
(or urllib2
for python2) by creating an urlopener. The list of handlers used to create this urlopener is retrieved by calling the u2handlers()
method on the transport class. This means that you can create your own transport by subclassing the default and overriding that method to use a HTTPSHander with a specific ssl context, e.g:
from suds.client import Client
from suds.transport.https import HttpAuthenticated
from urllib.request import HTTPSHandler
import ssl
class CustomTransport(HttpAuthenticated):
def u2handlers(self):
# use handlers from superclass
handlers = HttpAuthenticated.u2handlers(self)
# create custom ssl context, e.g.:
ctx = ssl.create_default_context(cafile="/path/to/ca-bundle.pem")
# configure context as needed...
ctx.check_hostname = False
# add a https handler using the custom context
handlers.append(HTTPSHandler(context=ctx))
return handlers
# instantiate client using this transport
c = Client("https://example.org/service?wsdl", transport=CustomTransport())