OpenAPITools / OpenAPITools/openapi-generator
SSL Exception when connecting to an HTTPS service
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
We use version 5.4.0 of the openapi generator. We have a nodejs service, and python and javascript clients.
We autogenerate our javascript and python client libraries to allow our javascript and python client applications to connect to our NodeJs OpenApi service.
I'm able to connect my python clients just fine to an HTTP instance of the service. In fact our javascript applications can connect both to HTTP and HTTPS service instances
However our python clients complain when we connect them to an HTTPS service instance.
I've updated the python code to pass in an ssl_ca_cert concatenated pem file. In the following I instantiate the Configuration class that is created by the OpenAPI generator.
self.configuration = Configuration(host, ssl_ca_cert=ssl_cert)
However I see the following error when I then try to hit a protected route on the HTTPS service.
<class 'urllib3.exceptions.MaxRetryError'>, MaxRetryError("HTTPSConnectionPool(host='changeme.com', port=8086): Max retries exceeded with url: /video (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1125)')))"), <traceback object at 0x7fbbbe122f80>
Though I've used OpenAPI successfully before, it has always been with HTTP. Its possible that I am simply missing something that I must do.
In the following I am showing the constructed RESTClientObject within the debugger. Here we see the ca_certs is set to my "test.pem" file.

And this next picture shows the point at which the request is about to go out:

The request seems to go out to the server, and I believe that the server is rejecting the request. However I'm not sure how to further resolve this issue. We tested this by shutting down the service, and verifying that the python client fails in a different way. Then we restarted the service and the client then reports the SSL verification error shown above.
We also have javascript openapi clients, and they are able to talk to the HTTPS service.. just fine. So this problem seems to be strictly with the generated python clients
I've further isolated the problem to the SSL handshake with the server:

we use openssl verion 1.1.1n

and python 3.8.8

and urllib 1.26.4

Any guidance would be appreciated.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the generated Python Configuration and RESTClientObject, then reproduce the HTTPS request using the supplied ssl_ca_cert against the protected route. Compare the behavior with the working HTTP and JavaScript clients and the reported Python 3.8.8, OpenSSL 1.1.1n, and urllib3 1.26.4 setup; done means the generated Python client completes certificate verification and the request succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, python
- Domain
- api, security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100