Suds over https with cert

前端 未结 5 1693
醉话见心
醉话见心 2020-12-07 15:47

I have soap service under Apache with ssl, suds works greate without ssl.
I have client certificate (my.crt and user.p12 files).
How I need to configure suds clien

5条回答
  •  时光取名叫无心
    2020-12-07 16:21

    SSL security feature is auto enabled python 2.7.9+ which breaks suds and other python libraries. I am sharing a patch which can fix this:

    Locate you suds library and replace u2handlers function in suds/trasnport/http.py file with following line:

    import ssl
    def u2handlers(self):
            """
            Get a collection of urllib handlers.
    
            @return: A list of handlers to be installed in the opener.
            @rtype: [Handler,...]
    
            """
            handlers = []
            unverified_context = ssl.create_default_context()
            unverified_context.check_hostname = False
            unverified_context.verify_mode = ssl.CERT_NONE
            unverified_handler = urllib2.HTTPSHandler(context=unverified_context)
            handlers.append(unverified_handler)
            handlers.append(urllib2.ProxyHandler(self.proxy))
            #handlers.append(urllib2.ProxyHandler(self.proxy))
            return handlers 
    

    Note: It's not a recommended way of doing it.

提交回复
热议问题