3

I'm trying to access a web service that uses a self-generated certificate using pysimplesoap and python 2.7.9

from pysimplesoap.client import SoapClient
import base64

username = 'webuser'
password = 'webpassword'
base64string = base64.encodestring('%s:%s' % (username, password)).replace('\n', '')

# real address / login removed
client = SoapClient(wsdl='https://url:port/webservice.asmx?WSDL',
http_headers={'Authorization': 'Basic %s'%base64string}, sessions=True,
cacert=None)

response = client.StatusInfo(... removed ...)
print(response)

Trying this throws the error message

urllib2.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)>

There are tips on how to bypass the problem by fixing urllib2, but is there a simpler way that allows me to tell pysimplesoap to ignore all SSL certificate client side errors. I'm using Windows7 and plan to port the code to a Raspian/Debian Linux, so a solution should not depend on the operating system.

Community
  • 1
  • 1
576i
  • 7,579
  • 12
  • 55
  • 92

1 Answers1

2

Answering my own question here, adding the 1st & 3rd line will ignore certification verification

import ssl 
from pysimplesoap.client import SoapClient 
ssl._create_default_https_context = ssl._create_unverified_context 

There's a longer discussion about this here where you can learn why this is not a good idea...

Community
  • 1
  • 1
576i
  • 7,579
  • 12
  • 55
  • 92