Search code examples
pythonrestsslswagger

Swagger - Python Client - Disable SSL verification


Using Swagger Editor, I have described my API and have downloaded the Swagger Python client (based on my API description) to test against my REST service (running in Wildfly on HTTPS).

I see in the configuration.py that comes with the Python client there is the following code block:

self.verify_ssl = True

I have set this value to false (for testing purposes), but I still continue to receive:

Exception when calling PApi->example_response_post: (0) Reason: SSLError [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)

When using the following test client:

# create an instance of the API class
api_instance = swagger_client.PApi()
body = swagger_client.exampleRequestBody("some stuff") 
http_client_timeout = 5.4 # float | Set the value of the http request timeout (optional)

try:
    # Product Types
    api_response = api_instance.example_response_post(body=body)
    pprint(api_response)
except ApiException as e:
    print "Exception when calling PApi->example_response_post: %s\n" % e

In fact, I dont think this configuration.py file is ever loaded. How can I go about making this work?

Thanks in advance!


Solution

  • For me a temporary workaround is to use http instead of https, you can unset it in the configuration.py just write http://.... instead of https:// for your hostname. For example: self.host = "http://localhost:8080"